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,8 +114,11 @@ class ComponentTool(BaseTool): ...@@ -115,8 +114,11 @@ class ComponentTool(BaseTool):
module._resetRegistry() module._resetRegistry()
self._resetModule(module) self._resetModule(module)
if reset_portal_type:
type_tool.resetDynamicDocumentsOnceAtTransactionBoundary() type_tool.resetDynamicDocumentsOnceAtTransactionBoundary()
return True
security.declareProtected(Permissions.ResetDynamicClasses, security.declareProtected(Permissions.ResetDynamicClasses,
'resetOnceAtTransactionBoundary') 'resetOnceAtTransactionBoundary')
def resetOnceAtTransactionBoundary(self): def resetOnceAtTransactionBoundary(self):
......
...@@ -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):
reset_performed = ComponentTool._original_reset(*args, **kwargs)
if reset_performed:
raise AssertionError("reset should not have been performed") raise AssertionError("reset should not have been performed")
def assertResetCalled(self, *args, **kwargs): return reset_performed
from Products.ERP5Type.Tool.ComponentTool import ComponentTool
def assertResetCalled(*args, **kwargs):
reset_performed = ComponentTool._original_reset(*args, **kwargs)
if reset_performed:
ComponentTool._reset_performed = True ComponentTool._reset_performed = True
return ComponentTool._original_reset(self, *args, **kwargs)
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