Commit bda37e96 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Fix startup of old Sites not having portal_components yet.

In such case, it must obviously be considered that the ZODB Component Document
was not found and thus fallback on filesystem Document.

2018-11-21 17:05:01,919 WARNING ERP5Type.Dynamic Could not access Portal Type Object for type 'Category Tool'
Traceback (most recent call last):
  File "product/ERP5Type/dynamic/lazy_class.py", line 3
52, in loadClass
    class_definition = generatePortalTypeClass(site, portal_type)
  File "product/ERP5Type/dynamic/portal_type_class.py",
 line 198, in generatePortalTypeClass
    module = erp5.component.document.find_load_module(type_class)
  File "product/ERP5Type/dynamic/component_package.py",
 line 361, in find_load_module
    loader = self.find_module(fullname)
  File "product/ERP5Type/dynamic/component_package.py",
 line 155, in find_module
    component_tool = aq_base(site.portal_components)
AttributeError: portal_components
parent 86ef0f8d
......@@ -136,7 +136,13 @@ class ComponentDynamicPackage(ModuleType):
id_ = "%s.%s.%s" % (self._id_prefix, version, name)
# aq_base() because this should not go up to ERP5Site and trigger
# side-effects, after all this only check for existence...
component = getattr(aq_base(site.portal_components), id_, None)
try:
component_tool = aq_base(site.portal_components)
except AttributeError:
# For old sites, just use FS Documents...
return None
component = getattr(component_tool, id_, None)
if component is None or component.getValidationState() not in ('modified',
'validated'):
return None
......@@ -152,7 +158,12 @@ class ComponentDynamicPackage(ModuleType):
# name=REFERENCE
else:
component_tool = aq_base(site.portal_components)
try:
component_tool = aq_base(site.portal_components)
except AttributeError:
# For old sites, just use FS Documents...
return None
for version in site.getVersionPriorityNameList():
id_ = "%s.%s.%s" % (self._id_prefix, version, name)
component = getattr(component_tool, id_, None)
......
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