Commit 12830504 authored by Arnaud Fontaine's avatar Arnaud Fontaine Committed by Łukasz Nowak

Do not mask exceptions when loading a Component.

(cherry picked from commit 7af4728b7463a521fadca3dcedbd5e445d9ef12e)
parent 0566435f
......@@ -110,7 +110,13 @@ class ComponentDynamicPackage(ModuleType):
# Only consider modified or validated states as state transition will
# be handled by component_validation_workflow which will take care of
# updating the registry
if component.getValidationState() in ('modified', 'validated'):
try:
validation_state_tuple = component.getValidationState()
except AttributeError:
# XXX: Accessors may have not been generated yet
pass
if validation_state_tuple in ('modified', 'validated'):
version = component.getVersion(validated_only=True)
# The versions should have always been set on ERP5Site property
# beforehand
......
......@@ -193,13 +193,14 @@ def generatePortalTypeClass(site, portal_type_name):
type_class_namespace = document_class_registry.get(type_class, '')
if not (type_class_namespace.startswith('Products.ERP5Type') or
portal_type_name in core_portal_type_class_dict):
try:
klass = getattr(__import__('erp5.component.document.' + type_class,
fromlist=['erp5.component.document'],
level=0),
type_class)
except (ImportError, AttributeError):
pass
import erp5.component.document
module_fullname = 'erp5.component.document.' + type_class
module_loader = erp5.component.document.find_module(module_fullname)
if module_loader is not None:
with Base.aq_method_lock:
module = module_loader(module_fullname)
klass = getattr(module, type_class)
if klass is None:
type_class_path = document_class_registry.get(type_class)
......
......@@ -43,15 +43,18 @@ def __call__(self, *args, **kw):
Component Extension if available, otherwise fallback on filesystem
Extension
"""
try:
f = getattr(__import__('erp5.component.extension.' + self._module,
fromlist=['erp5.component.extension'],
level=0),
self._function)
import erp5.component.extension
module_fullname = 'erp5.component.extension.' + self._module
module_loader = erp5.component.extension.find_module(module_fullname)
except (ImportError, AttributeError):
if module_loader is None:
return ExternalMethod__call__(self, *args, **kw)
else:
from Products.ERP5Type.Base import Base
with Base.aq_method_lock:
module = module_loader.load_module(module_fullname)
f = getattr(module, self._function)
_v_f = getattr(self, '_v_f', None)
if not _v_f or f is not _v_f:
f = self.getFunction(f=f)
......
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