Commit 32ab5744 authored by Nicolas Dumazet's avatar Nicolas Dumazet

add optional initialize parameter; and do not skip non-fake accessors


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42833 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 980a947a
...@@ -47,17 +47,20 @@ class AccessorHolderType(type): ...@@ -47,17 +47,20 @@ class AccessorHolderType(type):
def fromPropertyHolder(meta_type, def fromPropertyHolder(meta_type,
property_holder, property_holder,
portal=None, portal=None,
accessor_holder_module_name=None): accessor_holder_module_name=None,
initialize=True):
""" """
Create a new accessor holder class from the given Property Holder Create a new accessor holder class from the given Property Holder
within the given accessor holder module within the given accessor holder module
""" """
property_sheet_id = property_holder.__name__ property_sheet_id = property_holder.__name__
context = portal.portal_property_sheets
if initialize:
setDefaultClassProperties(property_holder) setDefaultClassProperties(property_holder)
try: try:
setDefaultProperties(property_holder, setDefaultProperties(property_holder,
object=portal, object=context,
portal=portal) portal=portal)
except: except:
LOG("Tool.PropertySheetTool", ERROR, LOG("Tool.PropertySheetTool", ERROR,
...@@ -86,6 +89,10 @@ class AccessorHolderType(type): ...@@ -86,6 +89,10 @@ class AccessorHolderType(type):
# Holder to the new accessor holder class (code coming from # Holder to the new accessor holder class (code coming from
# createAccessor in Base.PropertyHolder) # createAccessor in Base.PropertyHolder)
for id, fake_accessor in property_holder._getPropertyHolderItemList(): for id, fake_accessor in property_holder._getPropertyHolderItemList():
if callable(fake_accessor):
# not so fake ;)
setattr(accessor_holder_class, id, fake_accessor)
continue
if not isinstance(fake_accessor, tuple): if not isinstance(fake_accessor, tuple):
continue continue
...@@ -131,7 +138,7 @@ def _generateBaseAccessorHolder(portal, ...@@ -131,7 +138,7 @@ def _generateBaseAccessorHolder(portal,
property_holder = PropertyHolder(base_accessor_holder_id) property_holder = PropertyHolder(base_accessor_holder_id)
econtext = createExpressionContext(portal, portal) econtext = createExpressionContext(portal_categories, portal)
createRelatedAccessors(portal_categories, createRelatedAccessors(portal_categories,
property_holder, property_holder,
econtext, econtext,
...@@ -141,7 +148,7 @@ def _generateBaseAccessorHolder(portal, ...@@ -141,7 +148,7 @@ def _generateBaseAccessorHolder(portal,
property_holder, property_holder,
portal, portal,
'erp5.accessor_holder', 'erp5.accessor_holder',
skip_default=True) initialize=False)
setattr(accessor_holder_module, base_accessor_holder_id, accessor_holder) setattr(accessor_holder_module, base_accessor_holder_id, accessor_holder)
generating_base_accessors = False generating_base_accessors = False
return accessor_holder return accessor_holder
...@@ -177,7 +184,7 @@ def _generatePreferenceToolAccessorHolder(portal, accessor_holder_list, ...@@ -177,7 +184,7 @@ def _generatePreferenceToolAccessorHolder(portal, accessor_holder_list,
property_holder, property_holder,
portal, portal,
'erp5.accessor_holder', 'erp5.accessor_holder',
skip_default=True) initialize=False)
setattr(accessor_holder_module, 'PreferenceTool', accessor_holder) setattr(accessor_holder_module, 'PreferenceTool', accessor_holder)
return accessor_holder return accessor_holder
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