[Erp5-report] r40950 arnaud.fontaine - in /erp5/trunk/products: ERP5/Constraint/ ERP5/Docum...

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Dec 1 09:25:56 CET 2010


Author: arnaud.fontaine
Date: Wed Dec  1 09:25:56 2010
New Revision: 40950

URL: http://svn.erp5.org?rev=40950&view=rev
Log:
Fix missing condition checks for ZODB and filesystem Constraints by
modifying checkConsistency() to always check the condition and then
calling _checkConsistency() which is overriden in the child class


Modified:
    erp5/trunk/products/ERP5/Constraint/AccountTypeConstraint.py
    erp5/trunk/products/ERP5/Constraint/AccountingTransactionBalance.py
    erp5/trunk/products/ERP5/Constraint/BudgetConsumptionFeasability.py
    erp5/trunk/products/ERP5/Constraint/DocumentReferenceConstraint.py
    erp5/trunk/products/ERP5/Constraint/ResourceMeasuresConsistency.py
    erp5/trunk/products/ERP5/Constraint/TradeModelLineCellConsistency.py
    erp5/trunk/products/ERP5/Constraint/TransactionQuantityValueFeasability.py
    erp5/trunk/products/ERP5/Constraint/TransactionQuantityValueValidity.py
    erp5/trunk/products/ERP5/Document/AccountingTransactionBalanceConstraint.py
    erp5/trunk/products/ERP5/Document/ResourceMeasuresConsistencyConstraint.py
    erp5/trunk/products/ERP5/Document/TradeModelLineCellConsistencyConstraint.py
    erp5/trunk/products/ERP5/Document/TransactionQuantityValueFeasabilityConstraint.py
    erp5/trunk/products/ERP5/Document/TransactionQuantityValueValidityConstraint.py
    erp5/trunk/products/ERP5Type/Constraint/AttributeBlacklisted.py
    erp5/trunk/products/ERP5Type/Constraint/AttributeEquality.py
    erp5/trunk/products/ERP5Type/Constraint/AttributeUnicity.py
    erp5/trunk/products/ERP5Type/Constraint/CategoryAcquiredMembershipState.py
    erp5/trunk/products/ERP5Type/Constraint/CategoryExistence.py
    erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipArity.py
    erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipState.py
    erp5/trunk/products/ERP5Type/Constraint/CategoryRelatedMembershipState.py
    erp5/trunk/products/ERP5Type/Constraint/Constraint.py
    erp5/trunk/products/ERP5Type/Constraint/ContentExistence.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/Constraint/StringAttributeMatch.py
    erp5/trunk/products/ERP5Type/Constraint/TALESConstraint.py
    erp5/trunk/products/ERP5Type/Core/AttributeEqualityConstraint.py
    erp5/trunk/products/ERP5Type/Core/CategoryExistenceConstraint.py
    erp5/trunk/products/ERP5Type/Core/CategoryMembershipArityConstraint.py
    erp5/trunk/products/ERP5Type/Core/ContentExistenceConstraint.py
    erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py
    erp5/trunk/products/ERP5Type/Core/PropertyTypeValidityConstraint.py
    erp5/trunk/products/ERP5Type/Core/TALESConstraint.py
    erp5/trunk/products/ERP5Type/mixin/constraint.py

Modified: erp5/trunk/products/ERP5/Constraint/AccountTypeConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Constraint/AccountTypeConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Constraint/AccountTypeConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Constraint/AccountTypeConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -58,12 +58,9 @@ class AccountTypeConstraint(Constraint):
     ' of ${category}, this should have account_type'
     ' in ${account_type_list}')
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Implement here the consistency checker
     """
-    if not self._checkConstraintCondition(obj):
-      return []
-
     errors = []
     if getattr(obj, 'getAccountType', _MARKER) is _MARKER:
       errors.append(self._generateError(

Modified: erp5/trunk/products/ERP5/Constraint/AccountingTransactionBalance.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Constraint/AccountingTransactionBalance.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Constraint/AccountingTransactionBalance.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Constraint/AccountingTransactionBalance.py [utf8] Wed Dec  1 09:25:56 2010
@@ -41,12 +41,9 @@ class AccountingTransactionBalance(Const
   message_transaction_not_balanced_for_destination = translateString(
        'Transaction is not balanced for ${section_title}')
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Implement here the consistency checker
     """
-    if not self._checkConstraintCondition(obj):
-      return []
-
     error_list = []
     source_sum = dict()
     destination_sum = dict()

Modified: erp5/trunk/products/ERP5/Constraint/BudgetConsumptionFeasability.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Constraint/BudgetConsumptionFeasability.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Constraint/BudgetConsumptionFeasability.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Constraint/BudgetConsumptionFeasability.py [utf8] Wed Dec  1 09:25:56 2010
@@ -33,13 +33,10 @@ class BudgetConsumptionFeasability(Const
     Check if there is enough budget to consumed.
     """
 
-    def checkConsistency(self, object, fixit=0):
+    def _checkConsistency(self, object, fixit=0):
       """
       Check if there is enough budget to consumed.
       """
-      if not self._checkConstraintCondition(object):
-        return []
-
       errors = []
 
       new_category_list = []

Modified: erp5/trunk/products/ERP5/Constraint/DocumentReferenceConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Constraint/DocumentReferenceConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Constraint/DocumentReferenceConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Constraint/DocumentReferenceConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -54,13 +54,10 @@ class DocumentReferenceConstraint(Constr
       'Multiple (${document_count}) documents ${document_reference} - '
       '${document_language} - ${document_version} already exists')
 
-  def checkConsistency(self, document, fixit=0):
+  def _checkConsistency(self, document, fixit=0):
     """
       Implement here the consistency checker
     """
-    if not self._checkConstraintCondition(document):
-      return []
-
     # XXX we probably could check reference syntax here, based on regexp in
     # preferences?
     error_list = []

Modified: erp5/trunk/products/ERP5/Constraint/ResourceMeasuresConsistency.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Constraint/ResourceMeasuresConsistency.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Constraint/ResourceMeasuresConsistency.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Constraint/ResourceMeasuresConsistency.py [utf8] Wed Dec  1 09:25:56 2010
@@ -54,12 +54,9 @@ class ResourceMeasuresConsistency(Constr
     "Implicit measure for the management unit can't be created" \
     " because 'metric_type/${metric_type}' category doesn't exist."
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Implement here the consistency checker
     """
-    if not self._checkConstraintCondition(obj):
-      return []
-
     error_list = []
     portal = obj.getPortalObject()
 

Modified: erp5/trunk/products/ERP5/Constraint/TradeModelLineCellConsistency.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Constraint/TradeModelLineCellConsistency.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Constraint/TradeModelLineCellConsistency.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Constraint/TradeModelLineCellConsistency.py [utf8] Wed Dec  1 09:25:56 2010
@@ -41,13 +41,10 @@ class TradeModelLineCellConsistency(Cons
   message_cell_inexistance = translateString(
       'Missing cells on line "${line}"')
 
-  def checkConsistency(self, document, fixit=0):
+  def _checkConsistency(self, document, fixit=0):
     """
       Implement here the consistency checker
     """
-    if not self._checkConstraintCondition(document):
-      return []
-
     error_list = []
     base_id = self.constraint_definition['base_id']
     for cell_coordinates in document.getCellKeyList(base_id=base_id):

Modified: erp5/trunk/products/ERP5/Constraint/TransactionQuantityValueFeasability.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Constraint/TransactionQuantityValueFeasability.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Constraint/TransactionQuantityValueFeasability.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Constraint/TransactionQuantityValueFeasability.py [utf8] Wed Dec  1 09:25:56 2010
@@ -34,14 +34,11 @@ class TransactionQuantityValueFeasabilit
     for the source and the destination
     """
 
-    def checkConsistency(self, object, fixit=0):
+    def _checkConsistency(self, object, fixit=0):
       """
       Check if the quantity of the transaction is possible
       for the source and the destination
       """
-      if not self._checkConstraintCondition(object):
-          return []
-
       errors = []
       source_cell = object.getSourceValue()
       destination_cell = object.getDestinationValue()

Modified: erp5/trunk/products/ERP5/Constraint/TransactionQuantityValueValidity.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Constraint/TransactionQuantityValueValidity.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Constraint/TransactionQuantityValueValidity.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Constraint/TransactionQuantityValueValidity.py [utf8] Wed Dec  1 09:25:56 2010
@@ -33,14 +33,11 @@ class TransactionQuantityValueValidity(C
       Explain here what this constraint checker does
     """
 
-    def checkConsistency(self, object, fixit=0):
+    def _checkConsistency(self, object, fixit=0):
       """
       Check if the quantity of the transaction is greater than the 
       balance of the source.
       """
-      if not self._checkConstraintCondition(object):
-        return []
-
       errors = []
 
       source_cell = object.getSourceValue()

Modified: erp5/trunk/products/ERP5/Document/AccountingTransactionBalanceConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/AccountingTransactionBalanceConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/AccountingTransactionBalanceConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/AccountingTransactionBalanceConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -46,13 +46,10 @@ class AccountingTransactionBalanceConstr
                      PropertySheet.Reference,
                      PropertySheet.AccountingTransactionBalanceConstraint)
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """
     Check the object's consistency
     """
-    if not self.test(obj):
-      return []
-
     error_list = []
     source_sum = dict()
     destination_sum = dict()

Modified: erp5/trunk/products/ERP5/Document/ResourceMeasuresConsistencyConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/ResourceMeasuresConsistencyConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/ResourceMeasuresConsistencyConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/ResourceMeasuresConsistencyConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -48,13 +48,10 @@ class ResourceMeasuresConsistencyConstra
                      PropertySheet.Reference,
                      PropertySheet.ResourceMeasuresConsistencyConstraint)
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """
     Check the object's consistency
     """
-    if not self.test(obj):
-      return []
-
     error_list = []
     portal = obj.getPortalObject()
 

Modified: erp5/trunk/products/ERP5/Document/TradeModelLineCellConsistencyConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TradeModelLineCellConsistencyConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TradeModelLineCellConsistencyConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TradeModelLineCellConsistencyConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -47,13 +47,10 @@ class TradeModelLineCellConsistencyConst
                      PropertySheet.Reference,
                      PropertySheet.TradeModelLineCellConsistencyConstraint)
 
-  def checkConsistency(self, document, fixit=0):
+  def _checkConsistency(self, document, fixit=0):
     """
     Check the object's consistency
     """
-    if not self.test(document):
-      return []
-
     base_id = self.getBaseId()
     for cell_coordinates in document.getCellKeyList(base_id=base_id):
       if document.getCell(base_id=base_id, *cell_coordinates) is None:

Modified: erp5/trunk/products/ERP5/Document/TransactionQuantityValueFeasabilityConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TransactionQuantityValueFeasabilityConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TransactionQuantityValueFeasabilityConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TransactionQuantityValueFeasabilityConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -45,14 +45,11 @@ class TransactionQuantityValueFeasabilit
                        PropertySheet.Predicate,
                        PropertySheet.Reference)
 
-    def checkConsistency(self, object, fixit=0):
+    def _checkConsistency(self, object, fixit=0):
       """
       Check if the quantity of the transaction is possible
       for the source and the destination
       """
-      if not self.test(object):
-          return []
-
       errors = []
       source_cell = object.getSourceValue()
       destination_cell = object.getDestinationValue()

Modified: erp5/trunk/products/ERP5/Document/TransactionQuantityValueValidityConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TransactionQuantityValueValidityConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TransactionQuantityValueValidityConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TransactionQuantityValueValidityConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -42,14 +42,11 @@ class TransactionQuantityValueValidityCo
                        PropertySheet.Predicate,
                        PropertySheet.Reference)
 
-    def checkConsistency(self, object, fixit=0):
+    def _checkConsistency(self, object, fixit=0):
       """
       Check if the quantity of the transaction is greater than the
       balance of the source.
       """
-      if not self.test(object):
-          return []
-
       errors = []
 
       source_cell = object.getSourceValue()

Modified: erp5/trunk/products/ERP5Type/Constraint/AttributeBlacklisted.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/AttributeBlacklisted.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/AttributeBlacklisted.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/AttributeBlacklisted.py [utf8] Wed Dec  1 09:25:56 2010
@@ -47,14 +47,12 @@ class AttributeBlacklisted(PropertyExist
   message_invalid_attribute_blacklisted = "Attribute ${attribute_name}: "\
        "value is blacklisted"
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Check the object's consistency.
       We will make sure that each non None constraint_definition is 
       satisfied
     """
-    if not self._checkConstraintCondition(obj):
-      return []
-    errors = PropertyExistence.checkConsistency(self, obj, fixit=fixit)
+    errors = PropertyExistence._checkConsistency(self, obj, fixit=fixit)
     for attribute_name, expression_blacklisted_list in self.constraint_definition.items():
       message_id = None
       mapping = dict(attribute_name=attribute_name)

Modified: erp5/trunk/products/ERP5Type/Constraint/AttributeEquality.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/AttributeEquality.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/AttributeEquality.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/AttributeEquality.py [utf8] Wed Dec  1 09:25:56 2010
@@ -50,14 +50,12 @@ class AttributeEquality(PropertyExistenc
   message_invalid_attribute_value_fixed = "Attribute ${attribute_name} "\
        "value is ${current_value} but should be ${expected_value} (Fixed)"
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Check the object's consistency.
       We will make sure that each non None constraint_definition is 
       satisfied (equality)
     """
-    if not self._checkConstraintCondition(obj):
-      return []
-    errors = PropertyExistence.checkConsistency(self, obj, fixit=fixit)
+    errors = PropertyExistence._checkConsistency(self, obj, fixit=fixit)
     for attribute_name, expected_value in self.constraint_definition.items():
       message_id = None
       mapping = dict()

Modified: erp5/trunk/products/ERP5Type/Constraint/AttributeUnicity.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/AttributeUnicity.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/AttributeUnicity.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/AttributeUnicity.py [utf8] Wed Dec  1 09:25:56 2010
@@ -51,15 +51,13 @@ class AttributeUnicity(PropertyExistence
   message_invalid_attribute_unicity = "Attribute ${attribute_name} "\
        "value is ${value} but should be unique"
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Check the object's consistency.
       We will make sure that each non None constraint_definition is 
       satisfied (unicity)
       This Constraint use portal_catalog
     """
-    if not self._checkConstraintCondition(obj):
-      return []
-    errors = PropertyExistence.checkConsistency(self, obj, fixit=fixit)
+    errors = PropertyExistence._checkConsistency(self, obj, fixit=fixit)
     for attribute_name, expression_criterion_dict in self.constraint_definition.items():
       message_id = None
       mapping = dict(attribute_name=attribute_name)

Modified: erp5/trunk/products/ERP5Type/Constraint/CategoryAcquiredMembershipState.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/CategoryAcquiredMembershipState.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/CategoryAcquiredMembershipState.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/CategoryAcquiredMembershipState.py [utf8] Wed Dec  1 09:25:56 2010
@@ -52,11 +52,9 @@ class CategoryAcquiredMembershipState(Co
       "${workflow_variable} for object ${membership_url} is ${current_state} " \
       "which is not in ${valid_state_list}"
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Check the object's consistency.
     """
-    if not self._checkConstraintCondition(obj):
-      return []
     error_list = []
     # Retrieve values inside de PropertySheet (_constraints)
     base_category = self.constraint_definition['base_category']

Modified: erp5/trunk/products/ERP5Type/Constraint/CategoryExistence.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/CategoryExistence.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/CategoryExistence.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/CategoryExistence.py [utf8] Wed Dec  1 09:25:56 2010
@@ -55,11 +55,9 @@ class CategoryExistence(Constraint):
     return len(obj.getCategoryMembershipList(base_category,
                                              portal_type=portal_type))
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Check the object's consistency.
     """
-    if not self._checkConstraintCondition(obj):
-      return []
     error_list = []
     portal_type = self.constraint_definition.get('portal_type', ())
     # For each attribute name, we check if defined

Modified: erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipArity.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipArity.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipArity.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipArity.py [utf8] Wed Dec  1 09:25:56 2010
@@ -73,14 +73,12 @@ class CategoryMembershipArity(Constraint
     return len(obj.getCategoryMembershipList(base_category,
                                               portal_type=portal_type))
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Check the object's consistency.
       We are looking the definition of the constraing where
       are defined the minimum and the maximum arity, and the
       list of objects we wants to check the arity.
     """
-    if not self._checkConstraintCondition(obj):
-      return []
     error_list = []
     # Retrieve configuration values from PropertySheet (_constraints)
     base_category = self.constraint_definition['base_category']

Modified: erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipState.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipState.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipState.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/CategoryMembershipState.py [utf8] Wed Dec  1 09:25:56 2010
@@ -51,11 +51,9 @@ class CategoryMembershipState(Constraint
       "${workflow_variable} for object ${membership_url} is ${current_state} " \
       "which is not in ${valid_state_list}"
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Check the object's consistency.
     """
-    if not self._checkConstraintCondition(obj):
-      return []
     error_list = []
     # Retrieve values inside de PropertySheet (_constraints)
     base_category = self.constraint_definition['base_category']

Modified: erp5/trunk/products/ERP5Type/Constraint/CategoryRelatedMembershipState.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/CategoryRelatedMembershipState.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/CategoryRelatedMembershipState.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/CategoryRelatedMembershipState.py [utf8] Wed Dec  1 09:25:56 2010
@@ -51,11 +51,9 @@ class CategoryRelatedMembershipState(Cat
     },
   """
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Check the object's consistency.
     """
-    if not self._checkConstraintCondition(obj):
-      return []
     error_list = []
     # Retrieve values inside de PropertySheet (_constraints)
     base_category = self.constraint_definition['base_category']

Modified: erp5/trunk/products/ERP5Type/Constraint/Constraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/Constraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/Constraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/Constraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -104,6 +104,16 @@ class Constraint:
 
     def checkConsistency(self, obj, fixit=0, **kw):
       """
+      Check the object's consistency. Note that _checkConsistency()
+      should be overriden in the Constraints rather than this one.
+      """
+      if not self._checkConstraintCondition(obj):
+        return []
+
+      return self._checkConsistency(obj, fixit, **kw)
+
+    def _checkConsistency(self, obj, fixit=0, **kw):
+      """
         Default method is to return no error.
       """
       errors = []

Modified: erp5/trunk/products/ERP5Type/Constraint/ContentExistence.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/ContentExistence.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/ContentExistence.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/ContentExistence.py [utf8] Wed Dec  1 09:25:56 2010
@@ -48,27 +48,26 @@ class ContentExistence(Constraint):
   message_no_subobject_portal_type = "The document does not contain any"\
                    " subobject of portal portal type ${portal_type}"
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Checks that object contains a subobject.
     """
     from Products.ERP5Type.Message import Message
     error_list = []
-    if self._checkConstraintCondition(obj):
-      # Retrieve configuration values from PropertySheet (_constraints)
-      portal_type = self.constraint_definition.get('portal_type', ())
-      if not len(obj.contentValues(portal_type=portal_type)):
-        # Generate error message
-        mapping = {}
-        message_id = 'message_no_subobject'
-        if portal_type is not ():
-          message_id = 'message_no_subobject_portal_type'
-          # XXX maybe this could be factored out
-          if isinstance(portal_type, basestring):
-            portal_type = (portal_type, )
-          mapping['portal_type'] = str(Message('erp5_ui', ' or ')).join(
-              [str(Message('erp5_ui', pt)) for pt in portal_type])
-        # Add error
-        error_list.append(self._generateError(obj,
-                            self._getMessage(message_id), mapping))
+    # Retrieve configuration values from PropertySheet (_constraints)
+    portal_type = self.constraint_definition.get('portal_type', ())
+    if not len(obj.contentValues(portal_type=portal_type)):
+      # Generate error message
+      mapping = {}
+      message_id = 'message_no_subobject'
+      if portal_type is not ():
+        message_id = 'message_no_subobject_portal_type'
+        # XXX maybe this could be factored out
+        if isinstance(portal_type, basestring):
+          portal_type = (portal_type, )
+        mapping['portal_type'] = str(Message('erp5_ui', ' or ')).join(
+            [str(Message('erp5_ui', pt)) for pt in portal_type])
+      # Add error
+      error_list.append(self._generateError(obj,
+                          self._getMessage(message_id), mapping))
     return error_list
 

Modified: erp5/trunk/products/ERP5Type/Constraint/PortalTypeClass.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/PortalTypeClass.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/PortalTypeClass.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/PortalTypeClass.py [utf8] Wed Dec  1 09:25:56 2010
@@ -60,11 +60,9 @@ class PortalTypeClass(Constraint):
       " definition. Portal Type class is ${portal_type_class},"\
       " document class is ${document_class}"
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Check the object's consistency.
     """
-    if not self._checkConstraintCondition(obj):
-      return []
     error_list = []
     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=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/PropertyExistence.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/PropertyExistence.py [utf8] Wed Dec  1 09:25:56 2010
@@ -51,11 +51,9 @@ class PropertyExistence(Constraint):
   message_property_not_set = "Property existence error for property "\
             "${property_id}, this property is not defined"
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Check the object's consistency.
     """
-    if not self._checkConstraintCondition(obj):
-      return []
     error_list = []
     # For each attribute name, we check if defined
     for property_id in self.constraint_definition.keys():

Modified: erp5/trunk/products/ERP5Type/Constraint/PropertyTypeValidity.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/PropertyTypeValidity.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/PropertyTypeValidity.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/PropertyTypeValidity.py [utf8] Wed Dec  1 09:25:56 2010
@@ -75,12 +75,9 @@ class PropertyTypeValidity(Constraint):
     " should be of type ${expected_type} but is of type ${actual_type} (Fixed)"
   
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Check the object's consistency.
     """
-    if not self._checkConstraintCondition(obj):
-      return []
-
     error_list = []
     # For each attribute name, we check type
     for prop in obj.propertyMap():

Modified: erp5/trunk/products/ERP5Type/Constraint/StringAttributeMatch.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/StringAttributeMatch.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/StringAttributeMatch.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/StringAttributeMatch.py [utf8] Wed Dec  1 09:25:56 2010
@@ -47,11 +47,11 @@ class StringAttributeMatch(PropertyExist
   message_attribute_does_not_match = "Attribute ${attribute_name} is "\
      "${attribute_value} and does not match ${regular_expression}."
 
-  def checkConsistency(self, object, fixit=0):
+  def _checkConsistency(self, object, fixit=0):
     """Check the object's consistency.
     Check that each attribute matches the regular expression.
     """
-    error_list = PropertyExistence.checkConsistency(
+    error_list = PropertyExistence._checkConsistency(
                                   self, object, fixit=fixit)
     if not error_list:
       for attribute_name, regular_expression in\

Modified: erp5/trunk/products/ERP5Type/Constraint/TALESConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/TALESConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/TALESConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/TALESConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -63,13 +63,11 @@ class TALESConstraint(Constraint):
   message_expression_error = \
       "Error while evaluating expression: ${error_text}"
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """Check the object's consistency.
     """
     # import this later to prevent circular import
     from Products.ERP5Type.Utils import createExpressionContext
-    if not self._checkConstraintCondition(obj):
-      return []
     error_list = []
     expression_text = self.constraint_definition['expression']
     expression = Expression(expression_text)

Modified: erp5/trunk/products/ERP5Type/Core/AttributeEqualityConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/AttributeEqualityConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/AttributeEqualityConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/AttributeEqualityConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -66,13 +66,10 @@ class AttributeEqualityConstraint(Constr
 
   security.declareProtected(Permissions.AccessContentsInformation,
                             'checkConsistency')
-  def checkConsistency(self, obj, fixit=False):
+  def _checkConsistency(self, obj, fixit=False):
     """
     Check the object's consistency.
     """
-    if not self.test(obj):
-      return []
-
     attribute_name = self.getConstraintAttributeName()
 
     # If property does not exist, error will be raised by

Modified: erp5/trunk/products/ERP5Type/Core/CategoryExistenceConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/CategoryExistenceConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/CategoryExistenceConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/CategoryExistenceConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -59,13 +59,10 @@ class CategoryExistenceConstraint(Constr
 
   security.declareProtected(Permissions.AccessContentsInformation,
                             'checkConsistency')
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """
     Check the object's consistency.
     """
-    if not self.test(obj):
-      return []
-
     error_list = []
     portal_type_list = self.getConstraintPortalTypeList()
     # For each attribute name, we check if defined

Modified: erp5/trunk/products/ERP5Type/Core/CategoryMembershipArityConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/CategoryMembershipArityConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/CategoryMembershipArityConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/CategoryMembershipArityConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -65,15 +65,12 @@ class CategoryMembershipArityConstraint(
     return len(obj.getCategoryMembershipList(base_category_list,
                                              portal_type=portal_type_list))
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """
     Check the object's consistency. We are looking at the definition
     of the constraint where the minimum and the maximum arities are
     defined, and the list of objects we wants to check the arity for
     """
-    if not self.test(obj):
-      return []
-
     # Retrieve configuration values from PropertySheet
     base_category_list = self.getConstraintBaseCategoryList()
     min_arity = self.getMinArity()

Modified: erp5/trunk/products/ERP5Type/Core/ContentExistenceConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/ContentExistenceConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/ContentExistenceConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/ContentExistenceConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -62,14 +62,11 @@ class ContentExistenceConstraint(Constra
                      PropertySheet.Reference,
                      PropertySheet.ContentExistenceConstraint)
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """
     Checks that object contains at least one subobject and, if a list
     of Portal Type has been given, check their Portal Types
     """
-    if not self.test(obj):
-      return []
-
     portal_type = self._getExpressionValue(obj,
                                            self.getConstraintPortalType())
 

Modified: erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -61,13 +61,10 @@ class PropertyExistenceConstraint(Constr
 
   security.declareProtected(Permissions.AccessContentsInformation,
                             'checkConsistency')
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """
     Check the object's consistency.
     """
-    if not self.test(obj):
-      return []
-
     error_list = []
     # For each attribute name, we check if defined
     for property_id in self.getConstraintPropertyList():

Modified: erp5/trunk/products/ERP5Type/Core/PropertyTypeValidityConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/PropertyTypeValidityConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/PropertyTypeValidityConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/PropertyTypeValidityConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -68,13 +68,10 @@ class PropertyTypeValidityConstraint(Con
   # Properties of type eg. "object" can hold anything
   _permissive_type_list = ('object', 'data')
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """
     Check the object's consistency.
     """
-    if not self.test(obj):
-      return []
-
     error_list = []
     # For each attribute name, we check type
     for prop in obj.propertyMap():

Modified: erp5/trunk/products/ERP5Type/Core/TALESConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/TALESConstraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/TALESConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/TALESConstraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -66,14 +66,11 @@ class TALESConstraint(ConstraintMixin):
                      PropertySheet.Reference,
                      PropertySheet.TALESConstraint)
 
-  def checkConsistency(self, obj, fixit=0):
+  def _checkConsistency(self, obj, fixit=0):
     """
     Check that the Expression does not contain an error and is not
     evaluated to False
     """
-    if not self.test(obj):
-      return []
-
     expression_text = self.getExpression()
 
     try:

Modified: erp5/trunk/products/ERP5Type/mixin/constraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/mixin/constraint.py?rev=40950&r1=40949&r2=40950&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/mixin/constraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/mixin/constraint.py [utf8] Wed Dec  1 09:25:56 2010
@@ -76,10 +76,13 @@ class ConstraintMixin(Predicate):
                             'checkConsistency')
   def checkConsistency(self, obj, fixit=0, **kw):
     """
-    Default method is to return no error.
+    Check the pre-condition before checking the consistency.
+    _checkConsistency() must be define in the child class.
     """
-    errors = []
-    return errors
+    if not self.test(obj):
+      return []
+
+    return self._checkConsistency(obj, fixit, **kw)
 
   security.declareProtected(Permissions.AccessContentsInformation,
                             'fixConsistency')



More information about the Erp5-report mailing list