[Erp5-report] r41824 arnaud.fontaine - /erp5/trunk/products/ERP5Type/Core/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Dec 28 13:15:52 CET 2010


Author: arnaud.fontaine
Date: Tue Dec 28 13:15:52 2010
New Revision: 41824

URL: http://svn.erp5.org?rev=41824&view=rev
Log:
Get rid of useless getProperty() (see r41787) and add a method which
checks only one property so it could be used in child constraints
checking only one property


Modified:
    erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py

Modified: erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py?rev=41824&r1=41823&r2=41824&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py [utf8] Tue Dec 28 13:15:52 2010
@@ -57,26 +57,29 @@ class PropertyExistenceConstraint(Constr
   property_sheets = ConstraintMixin.property_sheets + \
                     (PropertySheet.PropertyExistenceConstraint,)
 
-  def _checkConsistency(self, obj, fixit=0):
+  def _checkPropertyConsistency(self, obj, property_id):
+    """
+    Check the consistency of the object only for the given Property ID
+    and is meaningful for child constraints which only need to check
+    one property
+    """
+    # Check whether the property exists and has been set
+    if not obj.hasProperty(property_id):
+      return "message_property_not_set"
+
+    return None
+
+  def _checkConsistency(self, obj, fixit=False):
     """
     Check the object's consistency.
     """
     error_list = []
     # For each attribute name, we check if defined
     for property_id in self.getConstraintPropertyList():
-      # Check existence of property
-      mapping = dict(property_id=property_id)
-      if not obj.hasProperty(property_id):
-        error_message_id = "message_no_such_property"
-      elif obj.getProperty(property_id) is None:
-        # If value is '', attribute is considered a defined
-        # XXX is this the default API ?
-        error_message_id = "message_property_not_set"
-      else:
-        error_message_id = None
-
-      if error_message_id:
+      error_message_id = self._checkPropertyConsistency(obj, property_id)
+      if error_message_id is not None:
         error_list.append(self._generateError(
-          obj, self._getMessage(error_message_id), mapping))
+          obj, self._getMessage(error_message_id),
+          dict(property_id=property_id)))
 
     return error_list



More information about the Erp5-report mailing list