Commit 95f3f8f5 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Speed up reset in __of__.

parent d702bf05
......@@ -340,15 +340,15 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
tv['ERP5Site.__of__'] = None
setSite(self)
# If Components are reset, then portal type classes should be reset
try:
reset_portal_type = self.portal_components.reset(force=False,
reset_portal_type=False)
# This should only happen before erp5_core is installed
component_tool = self.portal_components
except AttributeError:
reset_portal_type = False
# This should only happen before erp5_core is installed
synchronizeDynamicModules(self)
else:
# If Components are reset, then portal type classes should be reset
synchronizeDynamicModules(self, component_tool.reset())
synchronizeDynamicModules(self, force=True)
return self
def manage_beforeDelete(self, item, container):
......
......@@ -56,7 +56,7 @@ class ComponentTool(BaseTool):
security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declareProtected(Permissions.ResetDynamicClasses, 'reset')
def reset(self, force=True, reset_portal_type=True):
def reset(self, force=False, reset_portal_type=False):
"""
XXX-arnau: global reset
"""
......@@ -115,4 +115,5 @@ class ComponentTool(BaseTool):
key = 'ComponentTool.resetOnceAtTransactionBoundary'
if key not in tv:
tv[key] = None
transaction.get().addBeforeCommitHook(self.reset)
transaction.get().addBeforeCommitHook(self.reset,
args=(True, True))
......@@ -1254,7 +1254,7 @@ class _TestZodbComponent(SecurityTestCase):
self._component_tool = self.getPortal().portal_components
self._module = __import__(self._getComponentModuleName(),
fromlist=['erp5.component'])
self._component_tool.reset()
self._component_tool.reset(force=True, reset_portal_type=True)
@abc.abstractmethod
def _newComponent(self, reference, text_content, version='erp5'):
......@@ -1362,7 +1362,7 @@ class _TestZodbComponent(SecurityTestCase):
self.assertEquals(error_message, error_list[0])
self.assertEquals(component.getReference(), invalid_reference)
self.assertEquals(component.getReference(validated_only=True), valid_reference)
self._component_tool.reset()
self._component_tool.reset(force=True, reset_portal_type=True)
self.assertModuleImportable(valid_reference)
ComponentTool.reset = assertResetCalled
......@@ -1430,7 +1430,7 @@ class _TestZodbComponent(SecurityTestCase):
self.assertEquals(error_message, error_list[0])
self.assertEquals(component.getVersion(), invalid_version)
self.assertEquals(component.getVersion(validated_only=True), valid_version)
self._component_tool.reset()
self._component_tool.reset(force=True, reset_portal_type=True)
self.assertModuleImportable(reference)
ComponentTool.reset = assertResetCalled
......@@ -1495,7 +1495,7 @@ class _TestZodbComponent(SecurityTestCase):
self.assertTrue(error_list[0].startswith(error_message))
self.assertEquals(component.getTextContent(), invalid_code)
self.assertEquals(component.getTextContent(validated_only=True), valid_code)
self._component_tool.reset()
self._component_tool.reset(force=True, reset_portal_type=True)
self.assertModuleImportable('TestComponentWithSyntaxError')
ComponentTool.reset = assertResetCalled
......@@ -1780,7 +1780,7 @@ class TestPortalType(Person):
self.assertFalse(self._module.TestPortalType in person.__class__.mro())
# Reset Portal Type classes to ghost to make sure that everything is reset
self._component_tool.reset()
self._component_tool.reset(force=True, reset_portal_type=True)
# TestPortalType must be in available type class list
self.assertTrue('TestPortalType' in person_type.getDocumentTypeList())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment