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