Commit 3c43fe1f authored by Yoshinori Okuji's avatar Yoshinori Okuji

No need to hardcode so much for the bootstrap.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39386 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3d56ce87
......@@ -115,28 +115,7 @@ def portal_type_factory(portal_type_name):
mixin_list = []
interface_list = []
accessor_holder_list = []
# two exceptions that cant be loaded from types tool:
if portal_type_name == "Base Type":
# avoid chicken and egg issue:
# you can access portal_types/Foo if you havent
# loaded Base Type class, but you cant load
# Base Type class without accessing portal_types/Base Type
type_class = "ERP5TypeInformation"
elif portal_type_name == "Solver Type":
type_class = "SolverTypeInformation"
elif portal_type_name == "Business Template":
# When installing a BT, Business Templates are loaded
# before creating any Base Type object
type_class = "BusinessTemplate"
elif portal_type_name == "Base Category":
# 'elementary_type' is a Base Category needed for Standard
# Property and Acquired Property
type_class = "BaseCategory"
elif portal_type_name == "Category":
# 'elementary_type' sub-categories are needed for Standard
# Property and Acquired Property
type_class = "Category"
else:
from Products.ERP5.ERP5Site import getSite
site = getSite()
......@@ -151,6 +130,7 @@ def portal_type_factory(portal_type_name):
# type_class has a compatibility getter that should return
# something even if the field is not set (i.e. Base Type object
# was not migrated yet)
try:
type_class = portal_type.getTypeClass()
# But no such getter exists for Mixins and Interfaces:
......@@ -158,11 +138,29 @@ def portal_type_factory(portal_type_name):
try:
mixin_list = portal_type.getTypeMixinList()
interface_list = portal_type.getTypeInterfaceList()
except:
except StandardError:
# log loudly the error, but it's not _critical_
LOG("ERP5Type.Dynamic", ERROR,
"Could not load interfaces or Mixins for portal type %s" \
% portal_type_name)
except AttributeError:
# Try to figure out a coresponding document class from the document side.
# This is required for the bootstrap (e.g. Base Type).
for name, path in document_class_registry.iteritems():
# XXX heuristic: bootstrap issues should happen only inside ERP5Type.
if not path.startswith('Products.ERP5Type.'):
continue
klass = _import_class(path)
try:
try:
document_portal_type = getattr(klass, 'portal_type')
if document_portal_type == portal_type_name:
type_class = name
break
except AttributeError:
pass
finally:
del klass
import erp5
......
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