[Erp5-report] r43362 nicolas.dumazet - /erp5/trunk/products/ERP5Type/dynamic/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Feb 16 05:09:56 CET 2011


Author: nicolas.dumazet
Date: Wed Feb 16 05:09:55 2011
New Revision: 43362

URL: http://svn.erp5.org?rev=43362&view=rev
Log:
Do not generate twice category accessors from property sheets.

* cls._categories contains all categories associated to an object.
  This is list is aggregated and contains all categories associated
  by a property sheet, and all categories coming from the portal
  type definition itself.
* Categories defined on property sheets get their accessors generated
  and assigned on accessor holders.
* But categories defined on the portal type need to be generated
  distincly, on the portal type class itself. When doing so, we must
  generate accessors only for portal type categories, and ignore
  those already generated.

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

Modified: erp5/trunk/products/ERP5Type/dynamic/lazy_class.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/dynamic/lazy_class.py?rev=43362&r1=43361&r2=43362&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] Wed Feb 16 05:09:55 2011
@@ -208,10 +208,10 @@ class PortalTypeMetaClass(GhostBaseMetaC
 
     raise AttributeError
 
-  def generatePortalTypeAccessors(cls, site):
+  def generatePortalTypeAccessors(cls, site, portal_type_category_list):
     createAllCategoryAccessors(site,
                                cls,
-                               cls._categories,
+                               portal_type_category_list,
                                createExpressionContext(site, site))
     # make sure that category accessors from the portal type definition
     # are generated, no matter what
@@ -305,10 +305,12 @@ class PortalTypeMetaClass(GhostBaseMetaC
               "Could not access Portal Type Object for type %r"
               % portal_type, error=sys.exc_info())
           base_tuple = (ERP5BaseBroken, )
+          portal_type_category_list = []
           attribute_dict = dict(_categories=[], constraints=[])
           interface_list = []
         else:
-          base_tuple, interface_list, attribute_dict = class_definition
+          base_tuple, portal_type_category_list, \
+            interface_list, attribute_dict = class_definition
 
         klass.__isghost__ = False
         klass.__bases__ = base_tuple
@@ -325,7 +327,7 @@ class PortalTypeMetaClass(GhostBaseMetaC
         # because they dont have accessors, and will mess up
         # workflow methods. We KNOW that we will re-load this type anyway
         if len(base_tuple) > 1:
-          klass.generatePortalTypeAccessors(site)
+          klass.generatePortalTypeAccessors(site, portal_type_category_list)
           # need to set %s__roles__ for generated methods
           cls.setupSecurity()
 

Modified: erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py?rev=43362&r1=43361&r2=43362&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py [utf8] Wed Feb 16 05:09:55 2011
@@ -163,6 +163,8 @@ def generatePortalTypeClass(site, portal
 
   Returns tuple with 4 items:
     - base_tuple: a tuple of classes to be used as __bases__
+    - base_category_list: categories defined on the portal type
+        (and portal type only: this excludes property sheets)
     - interface_list: list of zope interfaces the portal type implements
     - attribute dictionary: any additional attributes to put on the class
   """
@@ -170,6 +172,7 @@ def generatePortalTypeClass(site, portal
 
   global core_portal_type_class_dict
 
+  portal_type_category_list = []
   attribute_dict = dict(portal_type=portal_type_name,
                         _categories=[],
                         constraints=[])
@@ -189,7 +192,7 @@ def generatePortalTypeClass(site, portal
 
       # Don't do anything else, just allow to load fully the outer
       # portal type class
-      return ((klass,), [], attribute_dict)
+      return ((klass,), [], [], attribute_dict)
 
   # Do not use __getitem__ (or _getOb) because portal_type may exist in a
   # type provider other than Types Tool.
@@ -212,7 +215,8 @@ def generatePortalTypeClass(site, portal
 
     mixin_list = portal_type.getTypeMixinList()
     interface_list = portal_type.getTypeInterfaceList()
-    attribute_dict['_categories'] = portal_type.getTypeBaseCategoryList()
+    portal_type_category_list = portal_type.getTypeBaseCategoryList()
+    attribute_dict['_categories'] = portal_type_category_list[:]
   else:
     LOG("ERP5Type.dynamic", WARNING,
         "Cannot find a portal type definition for '%s', trying to guess..."
@@ -346,6 +350,7 @@ def generatePortalTypeClass(site, portal
   #        % (portal_type_name, repr(baseclasses)))
 
   return (tuple(base_class_list),
+          portal_type_category_list,
           interface_class_list,
           attribute_dict)
 



More information about the Erp5-report mailing list