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,51 +399,8 @@ def initializeDynamicModules(): ...@@ -399,51 +399,8 @@ 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):
global _maybe_bootstrap
bootstrap = None
from Products.ERP5Type.Tool.PropertySheetTool import PropertySheetTool
from Products.ERP5Type.Tool.TypesTool import TypesTool
for tool_class in TypesTool, PropertySheetTool:
# if the instance has no property sheet tool, or incomplete
# property sheets, we need to import some data to bootstrap
# (only likely to happen on the first run ever)
tool_id = tool_class.id
tool = getattr(portal, tool_id, None)
if tool is None:
tool = tool_class()
try:
portal._setObject(tool_id, tool, set_owner=False, suppress_events=True)
except TypeError:
portal._setObject(tool_id, tool, set_owner=False)
tool = getattr(portal, tool_id)
elif not tool._isBootstrapRequired():
continue
if not bootstrap:
LOG('ERP5Site', INFO, 'bootstrap %s...' % tool_id)
from Products.ERP5.ERP5Site import getBootstrapDirectory
bootstrap = getBootstrapDirectory()
cwd = os.getcwd()
try:
os.chdir(bootstrap)
tool._bootstrap()
finally:
os.chdir(cwd)
if bootstrap:
if not getattr(portal, '_v_bootstrapping', False):
LOG('ERP5Site', INFO, 'Transition successful, please update your'
' business templates')
# XXX: if some portal types are missing, for instance
# if some Tools have no portal types, this is likely to fail with an
# error. On the other hand, we can't proceed without this change,
# and if we dont import the xml, the instance wont start.
portal.migrateToPortalTypeClass()
_maybe_bootstrap = lambda portal: None
last_sync = -1 last_sync = -1
_bootstrapped = set()
def synchronizeDynamicModules(context, force=False): def synchronizeDynamicModules(context, force=False):
""" """
Allow resetting all classes to ghost state, most likely done after Allow resetting all classes to ghost state, most likely done after
...@@ -473,7 +430,49 @@ def synchronizeDynamicModules(context, force=False): ...@@ -473,7 +430,49 @@ def synchronizeDynamicModules(context, force=False):
Base.aq_method_lock.acquire() Base.aq_method_lock.acquire()
try: try:
_maybe_bootstrap(portal) if portal.id not in _bootstrapped:
bootstrap = None
from Products.ERP5Type.Tool.PropertySheetTool import PropertySheetTool
from Products.ERP5Type.Tool.TypesTool import TypesTool
for tool_class in TypesTool, PropertySheetTool:
# if the instance has no property sheet tool, or incomplete
# property sheets, we need to import some data to bootstrap
# (only likely to happen on the first run ever)
tool_id = tool_class.id
tool = getattr(portal, tool_id, None)
if tool is None:
tool = tool_class()
try:
portal._setObject(tool_id, tool, set_owner=False, suppress_events=True)
except TypeError:
portal._setObject(tool_id, tool, set_owner=False)
tool = getattr(portal, tool_id)
elif not tool._isBootstrapRequired():
continue
if not bootstrap:
LOG('ERP5Site', INFO, 'bootstrap %s...' % tool_id)
from Products.ERP5.ERP5Site import getBootstrapDirectory
bootstrap = getBootstrapDirectory()
cwd = os.getcwd()
try:
os.chdir(bootstrap)
tool._bootstrap()
finally:
os.chdir(cwd)
if bootstrap:
if not getattr(portal, '_v_bootstrapping', False):
LOG('ERP5Site', INFO, 'Transition successful, please update your'
' business templates')
# XXX: if some portal types are missing, for instance
# if some Tools have no portal types, this is likely to fail with an
# error. On the other hand, we can't proceed without this change,
# and if we dont import the xml, the instance wont start.
portal.migrateToPortalTypeClass()
_bootstrapped.add(portal.id)
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