[Erp5-report] r10131 - in /erp5/trunk/products/ERP5Type: ./ Constraint/ Tool/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Sep 19 10:18:33 CEST 2006


Author: jerome
Date: Tue Sep 19 10:18:28 2006
New Revision: 10131

URL: http://svn.erp5.org?rev=10131&view=rev
Log:
rename checkConsistency argument to 'obj', because object is a builtin

Modified:
    erp5/trunk/products/ERP5Type/Base.py
    erp5/trunk/products/ERP5Type/Constraint/AttributeEquality.py
    erp5/trunk/products/ERP5Type/Constraint/CategoryAcquiredMembershipArity.py
    erp5/trunk/products/ERP5Type/Constraint/CategoryExistence.py
    erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipArity.py
    erp5/trunk/products/ERP5Type/Constraint/CategoryRelatedMembershipArity.py
    erp5/trunk/products/ERP5Type/Constraint/Constraint.py
    erp5/trunk/products/ERP5Type/Constraint/PortalTypeClass.py
    erp5/trunk/products/ERP5Type/Constraint/PropertyExistence.py
    erp5/trunk/products/ERP5Type/Constraint/PropertyTypeValidity.py
    erp5/trunk/products/ERP5Type/Tool/ClassTool.py

Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=10131&r1=10130&r2=10131&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py (original)
+++ erp5/trunk/products/ERP5Type/Base.py Tue Sep 19 10:18:28 2006
@@ -1811,9 +1811,9 @@
 
     for constraint_instance in self.constraints:
       if fixit:
-        error_list += constraint_instance.fixConsistency(object=self)
+        error_list += constraint_instance.fixConsistency(self)
       else:
-        error_list += constraint_instance.checkConsistency(object=self)
+        error_list += constraint_instance.checkConsistency(self)
 
     if len(error_list) > 0 and fixit:
       self.reindexObject()

Modified: erp5/trunk/products/ERP5Type/Constraint/AttributeEquality.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/AttributeEquality.py?rev=10131&r1=10130&r2=10131&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/AttributeEquality.py (original)
+++ erp5/trunk/products/ERP5Type/Constraint/AttributeEquality.py Tue Sep 19 10:18:28 2006
@@ -42,41 +42,41 @@
     },
   """
 
-  def checkConsistency(self, object, fixit=0):
+  def checkConsistency(self, obj, fixit=0):
     """
       This is the check method, we return a list of string,
       each string corresponds to an error.
       We will make sure that each non None constraint_definition is 
       satisfied (equality)
     """
-    errors = PropertyExistence.checkConsistency(self, object, fixit=fixit)
+    errors = PropertyExistence.checkConsistency(self, obj, fixit=fixit)
     for attribute_name, attribute_value in self.constraint_definition.items():
       error_message = None
       # If property does not exist, error will be raise by 
       # PropertyExistence Constraint.
-      if object.hasProperty(attribute_name):
+      if obj.hasProperty(attribute_name):
         identical = 1
         if type(attribute_value) in (type(()), type([])):
           # List type
-          if len(object.getProperty(attribute_name)) != len(attribute_value):
+          if len(obj.getProperty(attribute_name)) != len(attribute_value):
             identical = 0
           else:
-            for item in object.getProperty(attribute_name):
+            for item in obj.getProperty(attribute_name):
               if item not in attribute_value:
                 identical = 0
                 break
         else:
           # Other type
-          identical = (attribute_value == object.getProperty(attribute_name))
+          identical = (attribute_value == obj.getProperty(attribute_name))
         if not identical:
           # Generate error_message
           error_message =  "Attribute %s is '%s' but should be '%s'" % \
-              (attribute_name, object.getProperty(attribute_name), 
+              (attribute_name, obj.getProperty(attribute_name),
                attribute_value)
       # Generate error
       if error_message is not None:
         if fixit:
-          object._setProperty(attribute_name, attribute_value)
+          obj._setProperty(attribute_name, attribute_value)
           error_message += " (Fixed)"
-        errors.append(self._generateError(object, error_message))
+        errors.append(self._generateError(obj, error_message))
     return errors

Modified: erp5/trunk/products/ERP5Type/Constraint/CategoryAcquiredMembershipArity.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/CategoryAcquiredMembershipArity.py?rev=10131&r1=10130&r2=10131&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/CategoryAcquiredMembershipArity.py (original)
+++ erp5/trunk/products/ERP5Type/Constraint/CategoryAcquiredMembershipArity.py Tue Sep 19 10:18:28 2006
@@ -45,7 +45,7 @@
     },
   """
 
-  def checkConsistency(self, object, fixit=0):
+  def checkConsistency(self, obj, fixit=0):
     """
       This is the check method, we return a list of string,
       each string corresponds to an error.
@@ -60,7 +60,7 @@
     max_arity = int(self.constraint_definition['max_arity'])
     portal_type = self.constraint_definition['portal_type']
     # Check arity and compare it with the min and max
-    arity = len(object.getAcquiredCategoryMembershipList(base_category, 
+    arity = len(obj.getAcquiredCategoryMembershipList(base_category,
                                                  portal_type=portal_type))
     if (arity < min_arity) or (arity > max_arity):
       # Generate error message
@@ -72,5 +72,5 @@
           ", arity is equal to %i but should be between %i and %i" % \
           (arity, min_arity, max_arity)
       # Add error
-      errors.append(self._generateError(object, error_message))
+      errors.append(self._generateError(obj, error_message))
     return errors

Modified: erp5/trunk/products/ERP5Type/Constraint/CategoryExistence.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/CategoryExistence.py?rev=10131&r1=10130&r2=10131&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/CategoryExistence.py (original)
+++ erp5/trunk/products/ERP5Type/Constraint/CategoryExistence.py Tue Sep 19 10:18:28 2006
@@ -42,7 +42,7 @@
     },
   """
 
-  def checkConsistency(self, object, fixit=0):
+  def checkConsistency(self, obj, fixit=0):
     """
       This is the check method, we return a list of string,
       each string corresponds to an error.
@@ -56,9 +56,9 @@
       # Check existence of base category
       error_message = "Category existence error for base category '%s': " % \
                       base_category
-      if base_category not in object.getBaseCategoryList():
+      if base_category not in obj.getBaseCategoryList():
         error_message += " this document has no such category"
-      elif len(object.getCategoryMembershipList(base_category,
+      elif len(obj.getCategoryMembershipList(base_category,
                 portal_type = self.constraint_definition\
                                   .get('portal_type', ()))) == 0:
         error_message += " this category was not defined"
@@ -67,6 +67,6 @@
       
       # Raise error
       if error_message:
-        errors.append(self._generateError(object, error_message))
+        errors.append(self._generateError(obj, error_message))
     return errors
 

Modified: erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipArity.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipArity.py?rev=10131&r1=10130&r2=10131&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipArity.py (original)
+++ erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipArity.py Tue Sep 19 10:18:28 2006
@@ -45,7 +45,7 @@
     },
   """
 
-  def checkConsistency(self, object, fixit=0):
+  def checkConsistency(self, obj, fixit=0):
     """
       This is the check method, we return a list of string,
       each string corresponds to an error.
@@ -60,7 +60,7 @@
     max_arity = int(self.constraint_definition['max_arity'])
     portal_type = self.constraint_definition['portal_type']
     # Check arity and compare it with the min and max
-    arity = len(object.getCategoryMembershipList(base_category, 
+    arity = len(obj.getCategoryMembershipList(base_category, 
                                                  portal_type=portal_type))
     if (arity < min_arity) or (arity > max_arity):
       # Generate error message
@@ -72,5 +72,5 @@
           ", arity is equal to %i but should be between %i and %i" % \
           (arity, min_arity, max_arity)
       # Add error
-      errors.append(self._generateError(object, error_message))
+      errors.append(self._generateError(obj, error_message))
     return errors

Modified: erp5/trunk/products/ERP5Type/Constraint/CategoryRelatedMembershipArity.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/CategoryRelatedMembershipArity.py?rev=10131&r1=10130&r2=10131&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/CategoryRelatedMembershipArity.py (original)
+++ erp5/trunk/products/ERP5Type/Constraint/CategoryRelatedMembershipArity.py Tue Sep 19 10:18:28 2006
@@ -46,7 +46,7 @@
     },
     """
 
-    def checkConsistency(self, object, fixit=0):
+    def checkConsistency(self, obj, fixit=0):
       """
         This is the check method, we return a list of string,
         each string corresponds to an error.
@@ -61,7 +61,7 @@
       max_arity = int(self.constraint_definition['max_arity'])
       portal_type = self.constraint_definition['portal_type']
       # Check arity and compare it with the min and max
-      arity = len(object._getRelatedValueList(base_category, 
+      arity = len(obj._getRelatedValueList(base_category, 
                                               portal_type=portal_type))
       if (arity < min_arity) or (arity > max_arity):
         # Generate error message
@@ -73,5 +73,5 @@
             ", arity is equal to %i but should be between %i and %i" % \
             (arity, min_arity, max_arity)
         # Add error
-        errors.append(self._generateError(object, error_message))
+        errors.append(self._generateError(obj, error_message))
       return errors

Modified: erp5/trunk/products/ERP5Type/Constraint/Constraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/Constraint.py?rev=10131&r1=10130&r2=10131&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/Constraint.py (original)
+++ erp5/trunk/products/ERP5Type/Constraint/Constraint.py Tue Sep 19 10:18:28 2006
@@ -33,7 +33,7 @@
       Default Constraint implementation
     """
 
-    def __init__(self, id=None, description=None, type=None, 
+    def __init__(self, id=None, description=None, type=None,
                  **constraint_definition):
       """
         Remove unwanted attributes from constraint definition and keep
@@ -44,7 +44,7 @@
       self.type = type
       self.constraint_definition = constraint_definition
 
-    def edit(self, id=None, description=None, type=None, 
+    def edit(self, id=None, description=None, type=None,
              **constraint_definition):
       """
         Remove unwanted attributes from constraint definition and keep
@@ -55,27 +55,28 @@
       if type is not None: self.type = type
       self.constraint_definition.update(constraint_definition)
 
-    def _generateError(self, object, error_message):
+    def _generateError(self, obj, error_message):
       """
         Generic method used to generate error in checkConsistency.
       """
       error = None
       if error_message:
-        error = (object.getRelativeUrl(), 
-                 '%s inconsistency' % self.__class__.__name__, 
+        error = (obj.getRelativeUrl(),
+                 '%s inconsistency' % self.__class__.__name__,
                  104, error_message, self.description)
       return error
 
-    def checkConsistency(self, object, fixit=0):
+    def checkConsistency(self, obj, fixit=0):
       """
         Default method is to return no error.
       """
       errors = []
       return errors
 
-    def fixConsistency(self, object):
+    def fixConsistency(self, obj):
       """
         Default method is to call checkConsistency with
         fixit set to 1
       """
-      return self.checkConsistency(object, fixit=1)
+      return self.checkConsistency(obj, fixit=1)
+

Modified: erp5/trunk/products/ERP5Type/Constraint/PortalTypeClass.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/PortalTypeClass.py?rev=10131&r1=10130&r2=10131&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/PortalTypeClass.py (original)
+++ erp5/trunk/products/ERP5Type/Constraint/PortalTypeClass.py Tue Sep 19 10:18:28 2006
@@ -46,13 +46,11 @@
     },
   """
 
-  def checkConsistency(self, object, fixit=0):
+  def checkConsistency(self, obj, fixit=0):
     """
       This is the check method, we return a list of string,
       each string corresponds to an error.
     """
-    obj = object # FIXME: default argument should not use `object`
-                 # from python builtins
     errors = []
     types_tool = getToolByName(obj, 'portal_types')
     type_info = types_tool._getOb(obj.getPortalType(), None)

Modified: erp5/trunk/products/ERP5Type/Constraint/PropertyExistence.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/PropertyExistence.py?rev=10131&r1=10130&r2=10131&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/PropertyExistence.py (original)
+++ erp5/trunk/products/ERP5Type/Constraint/PropertyExistence.py Tue Sep 19 10:18:28 2006
@@ -43,7 +43,7 @@
     },
   """
 
-  def checkConsistency(self, object, fixit=0):
+  def checkConsistency(self, obj, fixit=0):
     """
       This is the check method, we return a list of string,
       each string corresponds to an error.
@@ -54,16 +54,16 @@
       # Check existence of property
       error_message = \
           "Property existence error for property '%s': " % property_id
-      if not object.hasProperty(property_id):
+      if not obj.hasProperty(property_id):
         error_message += " this document has no such property"
-      elif object.getProperty(property_id) is None:
+      elif obj.getProperty(property_id) is None:
         # If value is '', attribute is considered a defined
         # XXX is this the default API ?
         error_message += " this property was not defined"
       else:
         error_message = None
       # Return error
-      error = self._generateError(object, error_message)
+      error = self._generateError(obj, error_message)
       if error is not None:
         errors.append(error)
     return errors

Modified: erp5/trunk/products/ERP5Type/Constraint/PropertyTypeValidity.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/PropertyTypeValidity.py?rev=10131&r1=10130&r2=10131&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/PropertyTypeValidity.py (original)
+++ erp5/trunk/products/ERP5Type/Constraint/PropertyTypeValidity.py Tue Sep 19 10:18:28 2006
@@ -54,21 +54,21 @@
     'date':               (type(DateTime()), ),
   }
 
-  def checkConsistency(self, object, fixit=0):
+  def checkConsistency(self, obj, fixit=0):
     """
       This is the check method, we return a list of string,
       each string corresponds to an error.
     """
     errors = []
     # For each attribute name, we check type
-    for property in object.propertyMap():
-      property_id = property['id']
-      if property.get('multivalued', 0):
+    for prop in obj.propertyMap():
+      property_id = prop['id']
+      if prop.get('multivalued', 0):
         property_type = 'lines'
       else:
-        property_type = property['type']
+        property_type = prop['type']
       wrong_type = 0
-      value = object.getProperty(property_id)
+      value = obj.getProperty(property_id)
       if value is not None:
         # Check known type
         try:
@@ -77,7 +77,7 @@
           wrong_type = 0
           error_message = "Attribute %s is defined with unknown type %s" % \
                           (property_id, property_type)
-          errors.append(self._generateError(object, error_message))
+          errors.append(self._generateError(obj, error_message))
       if wrong_type:
         # Type is wrong, so, raise constraint error
         error_message = \
@@ -91,7 +91,7 @@
             except (KeyError, ValueError), error:
               error_message += " (Type cast failed : %s)" % error
             else:
-              object.setProperty(property_id, value)
+              obj.setProperty(property_id, value)
               error_message += " (Fixed)"
-        errors.append(self._generateError(object, error_message))
+        errors.append(self._generateError(obj, error_message))
     return errors

Modified: erp5/trunk/products/ERP5Type/Tool/ClassTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Tool/ClassTool.py?rev=10131&r1=10130&r2=10131&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/ClassTool.py (original)
+++ erp5/trunk/products/ERP5Type/Tool/ClassTool.py Tue Sep 19 10:18:28 2006
@@ -581,7 +581,7 @@
       Explain here what this constraint checker does
     \"\"\"
 
-    def checkConsistency(self, object, fixit = 0):
+    def checkConsistency(self, obj, fixit = 0):
       \"\"\"
         Implement here the consistency checker
         whenever fixit is not 0, object data should be updated to 




More information about the Erp5-report mailing list