Commit 3ed753c6 authored by Julien Muchembled's avatar Julien Muchembled

Fix several bootstrap issues

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43514 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b86e6662
...@@ -77,7 +77,7 @@ class BaseTool (UniqueObject, Folder): ...@@ -77,7 +77,7 @@ class BaseTool (UniqueObject, Folder):
id_set = set(x[:-4] for x in files if x[-4:] == '.xml') id_set = set(x[:-4] for x in files if x[-4:] == '.xml')
else: else:
id_set = set(quote(x) for x in content_id_list) id_set = set(quote(x) for x in content_id_list)
id_set.difference_update(self.objectIds()) id_set.difference_update(quote(x) for x in self.objectIds())
dirs[:] = id_set.intersection(dirs) dirs[:] = id_set.intersection(dirs)
for file in id_set: for file in id_set:
load(os.path.join(root, file + '.xml'), load(os.path.join(root, file + '.xml'),
......
...@@ -128,6 +128,8 @@ class TypesTool(TypeProvider): ...@@ -128,6 +128,8 @@ class TypesTool(TypeProvider):
'Standard Property', 'Standard Property',
'Acquired Property', 'Acquired Property',
'Dummy Class Tool', 'Dummy Class Tool',
# the following ones are required to upgrade an existing site
'Category Property',
)) ))
def listContentTypes(self, container=None): def listContentTypes(self, container=None):
......
...@@ -399,8 +399,38 @@ def initializeDynamicModules(): ...@@ -399,8 +399,38 @@ def initializeDynamicModules():
erp5.temp_portal_type = registerDynamicModule('erp5.temp_portal_type', erp5.temp_portal_type = registerDynamicModule('erp5.temp_portal_type',
loadTempPortalTypeClass) loadTempPortalTypeClass)
def _maybe_bootstrap(portal): last_sync = -1
global _maybe_bootstrap _bootstrapped = set()
def synchronizeDynamicModules(context, force=False):
"""
Allow resetting all classes to ghost state, most likely done after
adding and removing mixins on the fly
Most of the time, this reset is only hypothetic:
* with force=False, the reset is only done if another node resetted
the classes since the last reset on this node.
* with force=True, forcefully reset the classes on the current node
and send out an invalidation to other nodes
"""
portal = context.getPortalObject()
global last_sync
if force:
# hard invalidation to force sync between nodes
portal.newCacheCookie('dynamic_classes')
last_sync = portal.getCacheCookie('dynamic_classes')
else:
cookie = portal.getCacheCookie('dynamic_classes')
if cookie == last_sync:
# up to date, nothing to do
return
last_sync = cookie
import erp5
Base.aq_method_lock.acquire()
try:
if portal.id not in _bootstrapped:
bootstrap = None bootstrap = None
from Products.ERP5Type.Tool.PropertySheetTool import PropertySheetTool from Products.ERP5Type.Tool.PropertySheetTool import PropertySheetTool
from Products.ERP5Type.Tool.TypesTool import TypesTool from Products.ERP5Type.Tool.TypesTool import TypesTool
...@@ -441,39 +471,8 @@ def _maybe_bootstrap(portal): ...@@ -441,39 +471,8 @@ def _maybe_bootstrap(portal):
# and if we dont import the xml, the instance wont start. # and if we dont import the xml, the instance wont start.
portal.migrateToPortalTypeClass() portal.migrateToPortalTypeClass()
_maybe_bootstrap = lambda portal: None _bootstrapped.add(portal.id)
last_sync = -1
def synchronizeDynamicModules(context, force=False):
"""
Allow resetting all classes to ghost state, most likely done after
adding and removing mixins on the fly
Most of the time, this reset is only hypothetic:
* with force=False, the reset is only done if another node resetted
the classes since the last reset on this node.
* with force=True, forcefully reset the classes on the current node
and send out an invalidation to other nodes
"""
portal = context.getPortalObject()
global last_sync
if force:
# hard invalidation to force sync between nodes
portal.newCacheCookie('dynamic_classes')
last_sync = portal.getCacheCookie('dynamic_classes')
else:
cookie = portal.getCacheCookie('dynamic_classes')
if cookie == last_sync:
# up to date, nothing to do
return
last_sync = cookie
import erp5
Base.aq_method_lock.acquire()
try:
_maybe_bootstrap(portal)
LOG("ERP5Type.dynamic", 0, "Resetting dynamic classes") LOG("ERP5Type.dynamic", 0, "Resetting dynamic classes")
for class_name, klass in inspect.getmembers(erp5.portal_type, for class_name, klass in inspect.getmembers(erp5.portal_type,
inspect.isclass): inspect.isclass):
......
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