Commit 1d5da2b4 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Add properties of ZODB Property Sheets to the portal type property list



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40255 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fcea084e
...@@ -834,12 +834,23 @@ class Base( CopyContainer, ...@@ -834,12 +834,23 @@ class Base( CopyContainer,
def _propertyMap(self): def _propertyMap(self):
""" Method overload - properties are now defined on the ptype """ """ Method overload - properties are now defined on the ptype """
# Get all the accessor holders for ZODB Property Sheets
if hasattr(self.__class__, 'getAccessorHolderPropertyList'):
accessor_holder_property_list = \
tuple(self.__class__.getAccessorHolderPropertyList())
# Temporary portal type (such as 'TempBase' meaningful to display
# the objects being created/updated/removed on SVN update) does
# not inherit from any class of erp5.portal_type
else:
accessor_holder_property_list = ()
self._aq_dynamic('id') # Make sure aq_dynamic has been called once self._aq_dynamic('id') # Make sure aq_dynamic has been called once
property_holder = Base.aq_portal_type.get(self._aq_key()) property_holder = Base.aq_portal_type.get(self._aq_key())
if property_holder is None: if property_holder is None:
return ERP5PropertyManager._propertyMap(self) return ERP5PropertyManager._propertyMap(self)
return (tuple(getattr(property_holder, '_properties', ())) + return (tuple(getattr(property_holder, '_properties', ())) +
tuple(getattr(self, '_local_properties', ()))) tuple(getattr(self, '_local_properties', ())) +
accessor_holder_property_list)
def manage_historyCompare(self, rev1, rev2, REQUEST, def manage_historyCompare(self, rev1, rev2, REQUEST,
historyComparisonResults=''): historyComparisonResults=''):
......
...@@ -87,6 +87,20 @@ class PortalTypeMetaClass(ExtensionClass): ...@@ -87,6 +87,20 @@ class PortalTypeMetaClass(ExtensionClass):
""" """
return metacls.subclass_register.get(cls, []) return metacls.subclass_register.get(cls, [])
def getAccessorHolderPropertyList(cls):
"""
Get all the properties as defined in the accessor holders,
meaningful for _propertyMap for example
@see Products.ERP5Type.Base.Base._propertyMap
"""
property_list = []
for klass in cls.mro():
if klass.__module__ == 'erp5.accessor_holder':
property_list.extend(klass._properties)
return property_list
def resetAcquisitionAndSecurity(cls): def resetAcquisitionAndSecurity(cls):
# First, fill the __get__ slot of the class # First, fill the __get__ slot of the class
# that has been null'ed after resetting its __bases__ # that has been null'ed after resetting its __bases__
......
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