[Erp5-report] r43559 arnaud.fontaine - /erp5/trunk/products/ERP5Type/dynamic/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Feb 22 14:37:39 CET 2011


Author: arnaud.fontaine
Date: Tue Feb 22 14:37:39 2011
New Revision: 43559

URL: http://svn.erp5.org?rev=43559&view=rev
Log:
Generate accessors from properties which may be defined on the portal
type itself. This fixes testERP5eGov.


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=43559&r1=43558&r2=43559&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] Tue Feb 22 14:37:39 2011
@@ -7,7 +7,8 @@ from Products.ERP5Type.Accessor.Constant
 from Products.ERP5Type.Globals import InitializeClass
 from Products.ERP5Type.Base import Base as ERP5Base
 from Products.ERP5Type.Base import PropertyHolder, initializePortalTypeDynamicWorkflowMethods
-from Products.ERP5Type.Utils import createAllCategoryAccessors, createExpressionContext, UpperCase
+from Products.ERP5Type.Utils import createAllCategoryAccessors, \
+    createExpressionContext, UpperCase, setDefaultProperties
 from ExtensionClass import ExtensionClass, pmc_init_of
 
 from zope.interface import classImplements
@@ -213,6 +214,14 @@ class PortalTypeMetaClass(GhostBaseMetaC
                                cls,
                                portal_type_category_list,
                                createExpressionContext(site, site))
+
+    # Properties defined on the portal type itself are generated in
+    # erp5.portal_type directly, but this is unusual case (only
+    # PDFTypeInformation seems to use it)
+    portal_type_property_list = getattr(cls, '_properties', None)
+    if portal_type_property_list:
+      setDefaultProperties(cls)
+
     # make sure that category accessors from the portal type definition
     # are generated, no matter what
     # XXX this code is duplicated here, in PropertySheetTool, and in Base

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=43559&r1=43558&r2=43559&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py [utf8] Tue Feb 22 14:37:39 2011
@@ -175,6 +175,7 @@ def generatePortalTypeClass(site, portal
 
   portal_type_category_list = []
   attribute_dict = dict(portal_type=portal_type_name,
+                        _properties=[],
                         _categories=[],
                         constraints=[])
 
@@ -287,6 +288,20 @@ def generatePortalTypeClass(site, portal
         if property_sheet in zodb_property_sheet_name_set:
           property_sheet_name_set.add(property_sheet)
 
+      # PDFTypeInformation document class, for example, defines a
+      # method which generates dynamically properties and this is
+      # heavily used by egov
+      update_definition_dict = getattr(portal_type,
+                                       'updatePropertySheetDefinitionDict',
+                                       None)
+
+      if update_definition_dict is not None and not \
+         update_definition_dict.__module__.startswith('Products.ERP5Type.ERP5Type'):
+        try:
+          update_definition_dict(attribute_dict)
+        except AttributeError:
+          pass
+
     # XXX maybe this should be a generic hook, adding property sheets
     # dynamically for a given portal type name? If done well, this
     # system could perhaps help erp5_egov to get rid of aq_dynamic



More information about the Erp5-report mailing list