[Erp5-report] r40255 arnaud.fontaine - in /erp5/trunk/products/ERP5Type: ./ dynamic/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Nov 15 03:48:32 CET 2010


Author: arnaud.fontaine
Date: Mon Nov 15 03:48:32 2010
New Revision: 40255

URL: http://svn.erp5.org?rev=40255&view=rev
Log:
Add properties of ZODB Property Sheets to the portal type property list


Modified:
    erp5/trunk/products/ERP5Type/Base.py
    erp5/trunk/products/ERP5Type/dynamic/lazy_class.py

Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=40255&r1=40254&r2=40255&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Base.py [utf8] Mon Nov 15 03:48:32 2010
@@ -834,12 +834,23 @@ class Base( CopyContainer,
 
   def _propertyMap(self):
     """ 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
     property_holder = Base.aq_portal_type.get(self._aq_key())
     if property_holder is None:
       return ERP5PropertyManager._propertyMap(self)
     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,
                             historyComparisonResults=''):

Modified: erp5/trunk/products/ERP5Type/dynamic/lazy_class.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/dynamic/lazy_class.py?rev=40255&r1=40254&r2=40255&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] Mon Nov 15 03:48:32 2010
@@ -87,6 +87,20 @@ class PortalTypeMetaClass(ExtensionClass
     """
     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):
     # First, fill the __get__ slot of the class
     # that has been null'ed after resetting its __bases__




More information about the Erp5-report mailing list