From bda37e96fd4f4e26e46af3f821edae430e4cc543 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Wed, 21 Nov 2018 18:49:53 +0900 Subject: [PATCH] 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 --- product/ERP5Type/dynamic/component_package.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/product/ERP5Type/dynamic/component_package.py b/product/ERP5Type/dynamic/component_package.py index 932ed48bb1..eb0cc76e08 100644 --- a/product/ERP5Type/dynamic/component_package.py +++ b/product/ERP5Type/dynamic/component_package.py @@ -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) -- 2.25.1