Commit 854bc009 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Make sure that Components are properly reset on all ZEO clients.

parent bb7855ca
...@@ -339,7 +339,16 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin): ...@@ -339,7 +339,16 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
if 'ERP5Site.__of__' not in tv and type(parent) is Application: if 'ERP5Site.__of__' not in tv and type(parent) is Application:
tv['ERP5Site.__of__'] = None tv['ERP5Site.__of__'] = None
setSite(self) setSite(self)
synchronizeDynamicModules(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
except AttributeError:
reset_portal_type = False
synchronizeDynamicModules(self, force=reset_portal_type)
return self return self
def manage_beforeDelete(self, item, container): def manage_beforeDelete(self, item, container):
......
...@@ -41,7 +41,7 @@ from Products.ERP5Type.TransactionalVariable import getTransactionalVariable ...@@ -41,7 +41,7 @@ from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from zLOG import LOG, INFO, WARNING from zLOG import LOG, INFO, WARNING
_last_sync = -1 last_sync = -1
class ComponentTool(BaseTool): class ComponentTool(BaseTool):
""" """
This tool provides methods to load the the different types of This tool provides methods to load the the different types of
...@@ -72,7 +72,7 @@ class ComponentTool(BaseTool): ...@@ -72,7 +72,7 @@ class ComponentTool(BaseTool):
delattr(module, name) delattr(module, name)
security.declareProtected(Permissions.ResetDynamicClasses, 'reset') security.declareProtected(Permissions.ResetDynamicClasses, 'reset')
def reset(self, force=True): def reset(self, force=True, reset_portal_type=True):
""" """
XXX-arnau: global reset XXX-arnau: global reset
""" """
...@@ -89,8 +89,7 @@ class ComponentTool(BaseTool): ...@@ -89,8 +89,7 @@ class ComponentTool(BaseTool):
else: else:
cookie = portal.getCacheCookie('component_packages') cookie = portal.getCacheCookie('component_packages')
if cookie == last_sync: if cookie == last_sync:
type_tool.resetDynamicDocumentsOnceAtTransactionBoundary() return False
return
last_sync = cookie last_sync = cookie
LOG("ERP5Type.Tool.ComponentTool", INFO, "Resetting Components") LOG("ERP5Type.Tool.ComponentTool", INFO, "Resetting Components")
...@@ -115,7 +114,10 @@ class ComponentTool(BaseTool): ...@@ -115,7 +114,10 @@ class ComponentTool(BaseTool):
module._resetRegistry() module._resetRegistry()
self._resetModule(module) self._resetModule(module)
type_tool.resetDynamicDocumentsOnceAtTransactionBoundary() if reset_portal_type:
type_tool.resetDynamicDocumentsOnceAtTransactionBoundary()
return True
security.declareProtected(Permissions.ResetDynamicClasses, security.declareProtected(Permissions.ResetDynamicClasses,
'resetOnceAtTransactionBoundary') 'resetOnceAtTransactionBoundary')
......
...@@ -1209,12 +1209,18 @@ ComponentTool._original_reset = ComponentTool.reset ...@@ -1209,12 +1209,18 @@ ComponentTool._original_reset = ComponentTool.reset
ComponentTool._reset_performed = False ComponentTool._reset_performed = False
def assertResetNotCalled(*args, **kwargs): def assertResetNotCalled(*args, **kwargs):
raise AssertionError("reset should not have been performed") reset_performed = ComponentTool._original_reset(*args, **kwargs)
if reset_performed:
raise AssertionError("reset should not have been performed")
def assertResetCalled(self, *args, **kwargs): return reset_performed
from Products.ERP5Type.Tool.ComponentTool import ComponentTool
ComponentTool._reset_performed = True def assertResetCalled(*args, **kwargs):
return ComponentTool._original_reset(self, *args, **kwargs) reset_performed = ComponentTool._original_reset(*args, **kwargs)
if reset_performed:
ComponentTool._reset_performed = True
return reset_performed
import abc import abc
......
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