Commit e002a807 authored by Jérome Perrin's avatar Jérome Perrin

don't fail if Preference portal type is not installed.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13016 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 82b837de
...@@ -42,8 +42,6 @@ from Products.ERP5Form import _dtmldir ...@@ -42,8 +42,6 @@ from Products.ERP5Form import _dtmldir
from Products.ERP5Form.Document.Preference import Priority from Products.ERP5Form.Document.Preference import Priority
class func_code: pass
def updatePreferenceClassPropertySheetList(): def updatePreferenceClassPropertySheetList():
# The Preference class should be imported from the common location # The Preference class should be imported from the common location
# in ERP5Type since it could be overloaded in another product # in ERP5Type since it could be overloaded in another product
...@@ -60,6 +58,7 @@ def updatePreferenceClassPropertySheetList(): ...@@ -60,6 +58,7 @@ def updatePreferenceClassPropertySheetList():
class_property_sheet_list = tuple(property_sheets) class_property_sheet_list = tuple(property_sheets)
Preference.property_sheets = class_property_sheet_list Preference.property_sheets = class_property_sheet_list
def createPreferenceToolAccessorList(portal) : def createPreferenceToolAccessorList(portal) :
""" """
Initialize all Preference methods on the preference tool. Initialize all Preference methods on the preference tool.
...@@ -73,17 +72,18 @@ def createPreferenceToolAccessorList(portal) : ...@@ -73,17 +72,18 @@ def createPreferenceToolAccessorList(portal) :
typestool = getToolByName(portal, 'portal_types') typestool = getToolByName(portal, 'portal_types')
pref_portal_type = typestool.getTypeInfo('Preference') pref_portal_type = typestool.getTypeInfo('Preference')
if pref_portal_type is None: if pref_portal_type is None:
LOG('createPreferenceToolAccessor', PROBLEM, LOG('ERP5Form.PreferenceTool', PROBLEM,
'Preference type information is not installed.') 'Preference type information is not installed.')
# 'Dynamic' property sheets added through ZMI else:
zmi_property_sheet_list = [] # 'Dynamic' property sheets added through ZMI
for property_sheet in pref_portal_type.property_sheet_list : zmi_property_sheet_list = []
try: for property_sheet in pref_portal_type.property_sheet_list :
zmi_property_sheet_list.append( try:
getattr(__import__(property_sheet), property_sheet)) zmi_property_sheet_list.append(
except ImportError, e : getattr(__import__(property_sheet), property_sheet))
LOG('createPreferenceToolAccessor', PROBLEM, except ImportError, e :
'unable to import Property Sheet %s' % property_sheet, e) LOG('ERP5Form.PreferenceTool', PROBLEM,
'unable to import Property Sheet %s' % property_sheet, e)
# 'Static' property sheets defined on the class # 'Static' property sheets defined on the class
# The Preference class should be imported from the common location # The Preference class should be imported from the common location
# in ERP5Type since it could be overloaded in another product # in ERP5Type since it could be overloaded in another product
...@@ -104,7 +104,10 @@ def createPreferenceToolAccessorList(portal) : ...@@ -104,7 +104,10 @@ def createPreferenceToolAccessorList(portal) :
for attribute_name in attr_list: for attribute_name in attr_list:
method = PreferenceMethod(attribute_name) method = PreferenceMethod(attribute_name)
setattr(PreferenceTool, attribute_name, method) setattr(PreferenceTool, attribute_name, method)
class func_code: pass
class PreferenceMethod(Method) : class PreferenceMethod(Method) :
""" A method object that lookup the attribute on preferences. """ """ A method object that lookup the attribute on preferences. """
# This is required to call the method form the Web # This is required to call the method form the Web
......
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