Commit dc4ddee4 authored by Arnaud Fontaine's avatar Arnaud Fontaine

When loading a Portal Type class, try first to load Document Components.

This is hackish and hardcoded for now because it's only for bt5 Documents. It
should be more generic (for non-bt5 Documents), but this is tricky from a
bootstrap point of view, so keep it simple for now.
parent b1e92e1b
...@@ -182,16 +182,26 @@ def generatePortalTypeClass(site, portal_type_name): ...@@ -182,16 +182,26 @@ def generatePortalTypeClass(site, portal_type_name):
raise AttributeError('Document class is not defined on Portal Type %s' \ raise AttributeError('Document class is not defined on Portal Type %s' \
% portal_type_name) % portal_type_name)
klass = None
if '.' in type_class: if '.' in type_class:
type_class_path = type_class type_class_path = type_class
else: else:
type_class_path = document_class_registry.get(type_class) type_class_path = document_class_registry.get(type_class, None)
if type_class_path is None:
# XXX-arnau: hardcoded but this must be improved anyway when Products will
# be in ZODB, for now this should be enough to only care of bt5 Documents
if type_class_path is None or type_class_path.startswith('erp5.document'):
import erp5.component.document
module = getattr(erp5.component.document, type_class, None)
klass = module and getattr(module, type_class, None) or None
if klass is None and type_class_path is None:
raise AttributeError('Document class %s has not been registered:' raise AttributeError('Document class %s has not been registered:'
' cannot import it as base of Portal Type %s' ' cannot import it as base of Portal Type %s'
% (type_class, portal_type_name)) % (type_class, portal_type_name))
klass = _importClass(type_class_path) if klass is None:
klass = _importClass(type_class_path)
global property_sheet_generating_portal_type_set global property_sheet_generating_portal_type_set
......
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