Commit 51119b63 authored by Nicolas Dumazet's avatar Nicolas Dumazet

compatibility of preference system with zodb property sheets

Soon enough, all Preferences will be defined in property sheet tool, and
this code will not be needed anymore


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42012 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 837e21b4
......@@ -53,6 +53,8 @@ class Priority:
USER = 3
def updatePreferenceClassPropertySheetList():
# XXX obsolete, and now handled in dynamic.portal_type_class
from Products.ERP5Form.Document.Preference import Preference
# 'Static' property sheets defined on the class
class_property_sheet_list = Preference.property_sheets
......@@ -61,7 +63,7 @@ def updatePreferenceClassPropertySheetList():
for id in dir(PropertySheet):
if id.endswith('Preference'):
ps = getattr(PropertySheet, id)
if ps not in property_sheets:
if not isinstance(ps, basestring) and ps not in property_sheets:
property_sheets.append(ps)
class_property_sheet_list = tuple(property_sheets)
Preference.property_sheets = class_property_sheet_list
......@@ -78,6 +80,17 @@ def createPreferenceToolAccessorList(portal) :
"""
property_list = []
# 'Static' property sheets defined on the class
# The Preference class should be imported from the common location
# in ERP5Type since it could be overloaded in another product
from Products.ERP5Type.Document.Preference import Preference
for property_sheet in Preference.property_sheets:
if not isinstance(property_sheet, basestring):
property_list += property_sheet._properties
if not len(property_list):
return
# 'Dynamic' property sheets added by portal_type
pref_portal_type = portal.portal_types.getTypeInfo('Preference')
if pref_portal_type is None:
......@@ -87,12 +100,6 @@ def createPreferenceToolAccessorList(portal) :
pref_portal_type.updatePropertySheetDefinitionDict(
{'_properties': property_list})
# 'Static' property sheets defined on the class
# The Preference class should be imported from the common location
# in ERP5Type since it could be overloaded in another product
from Products.ERP5Type.Document.Preference import Preference
for property_sheet in Preference.property_sheets:
property_list += property_sheet._properties
# Generate common method names
for prop in property_list:
......@@ -201,6 +208,8 @@ class PreferenceTool(BaseTool):
return default
def _aq_dynamic(self, id):
# XXX as soon as zodb property sheets are put everywhere, this can
# be safely deleted
base_value = PreferenceTool.inheritedAttribute('_aq_dynamic')(self, id)
if not PreferenceTool.aq_preference_generated:
updatePreferenceClassPropertySheetList()
......
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