Commit 124b1619 authored by Julien Muchembled's avatar Julien Muchembled

Make sure automatic migration of core tools does not modify ZODB when if fails

parent 5b8ec677
......@@ -30,6 +30,7 @@
import sys
import os
import inspect
import transaction
from types import ModuleType
from Products.ERP5Type.dynamic.dynamic_module import registerDynamicModule
......@@ -42,7 +43,7 @@ from Products.ERP5Type.dynamic.accessor_holder import AccessorHolderModuleType,
createAllAccessorHolderList
from Products.ERP5Type.TransactionalVariable import TransactionalResource
from zLOG import LOG, ERROR, INFO, WARNING
from zLOG import LOG, ERROR, INFO, WARNING, PANIC
def _importClass(classpath):
try:
......@@ -346,6 +347,7 @@ def synchronizeDynamicModules(context, force=False):
migrate = False
from Products.ERP5Type.Tool.PropertySheetTool import PropertySheetTool
from Products.ERP5Type.Tool.TypesTool import TypesTool
try:
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
......@@ -354,7 +356,8 @@ def synchronizeDynamicModules(context, force=False):
tool = getattr(portal, tool_id, None)
if tool is None:
tool = tool_class()
portal._setObject(tool_id, tool, set_owner=False, suppress_events=True)
portal._setObject(tool_id, tool, set_owner=False,
suppress_events=True)
tool = getattr(portal, tool_id)
elif tool._isBootstrapRequired():
migrate = True
......@@ -372,6 +375,12 @@ def synchronizeDynamicModules(context, force=False):
' business templates')
else:
_bootstrapped.add(portal.id)
except:
# Required because the exception may be silently dropped by the caller.
transaction.doom()
LOG('ERP5Site', PANIC, "Automatic migration of type and"
" property sheet tool failed", error=sys.exc_info())
raise
LOG("ERP5Type.dynamic", 0, "Resetting dynamic classes")
try:
......
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