[Erp5-report] r39942 arnaud.fontaine - /erp5/trunk/products/ERP5Type/Utils.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Nov 5 07:21:05 CET 2010


Author: arnaud.fontaine
Date: Fri Nov  5 07:21:04 2010
New Revision: 39942

URL: http://svn.erp5.org?rev=39942&view=rev
Log:
Add constraints of ZODB Property Sheets to the list of property holder
constraints and check whether the object given to setDefaultProperties
is not None before getting its portal_type


Modified:
    erp5/trunk/products/ERP5Type/Utils.py

Modified: erp5/trunk/products/ERP5Type/Utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Utils.py?rev=39942&r1=39941&r2=39942&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Utils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Utils.py [utf8] Fri Nov  5 07:21:04 2010
@@ -1514,9 +1514,17 @@ def setDefaultProperties(property_holder
       # Unnecessary to create these accessors more than once.
       base_category_dict.clear()
 
+    from Products.ERP5Type.mixin.constraint import ConstraintMixin
     property_holder.constraints = []
     for const in constraint_list:
-      createConstraintList(property_holder, constraint_definition=const)
+      # ZODB Property Sheets constraints are no longer defined by a
+      # dictionnary but by a ConstraintMixin, thus just append it to
+      # the list of constraints
+      if isinstance(const, ConstraintMixin):
+        property_holder.constraints.append(const)
+      else:
+        createConstraintList(property_holder, constraint_definition=const)
+
     # ERP5 _properties and Zope _properties are somehow different
     # The id is converted to the Zope standard - we keep the original id
     # as base_id
@@ -1567,7 +1575,7 @@ def setDefaultProperties(property_holder
 
     # Create for every portal type group an accessor (like isPortalDeliveryType)
     # In the future, this should probalby use categories
-    if portal is not None: # we can not do anything without portal
+    if portal is not None and object is not None: # we can not do anything without portal
       # import lately in order to avoid circular dependency
       from Products.ERP5Type.ERP5Type import ERP5TypeInformation
       portal_type = object.portal_type




More information about the Erp5-report mailing list