Commit bd7c3ae5 authored by Jérome Perrin's avatar Jérome Perrin

Documentation fixes, "This is the check method, we return a list of string,

each string corresponds to an error" was wrong, constraints returns some
ConsistencyMessage instances



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21030 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 128682f6
...@@ -51,9 +51,7 @@ class AttributeEquality(PropertyExistence): ...@@ -51,9 +51,7 @@ class AttributeEquality(PropertyExistence):
"value is ${current_value} but should be ${expected_value} (Fixed)" "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.
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 We will make sure that each non None constraint_definition is
satisfied (equality) satisfied (equality)
""" """
......
...@@ -33,10 +33,10 @@ from Products.ERP5Type.Constraint.CategoryMembershipArity \ ...@@ -33,10 +33,10 @@ from Products.ERP5Type.Constraint.CategoryMembershipArity \
class CategoryAcquiredMembershipArity(CategoryMembershipArity): class CategoryAcquiredMembershipArity(CategoryMembershipArity):
""" """
This method check and fix if an object respects the arity. This method checks if an object respects the arity.
For example we can check if every Order has at
least one source. For example we can check if every Order has at least one source.
Configuration exemple: Configuration example:
{ 'id' : 'source', { 'id' : 'source',
'description' : '', 'description' : '',
'type' : 'CategoryAcquiredMembershipArity', 'type' : 'CategoryAcquiredMembershipArity',
......
...@@ -56,9 +56,7 @@ class CategoryExistence(Constraint): ...@@ -56,9 +56,7 @@ class CategoryExistence(Constraint):
portal_type=portal_type)) portal_type=portal_type))
def checkConsistency(self, obj, fixit=0): def checkConsistency(self, obj, fixit=0):
""" """Check the object's consistency.
This is the check method, we return a list of string,
each string corresponds to an error.
""" """
if not self._checkConstraintCondition(obj): if not self._checkConstraintCondition(obj):
return [] return []
...@@ -85,8 +83,8 @@ class CategoryExistence(Constraint): ...@@ -85,8 +83,8 @@ class CategoryExistence(Constraint):
class CategoryAcquiredExistence(CategoryExistence): class CategoryAcquiredExistence(CategoryExistence):
"""This constraint check an object respects the existence of a category, with """This constraint checks if an object respects the existence of a category,
acquisition. with acquisition.
Configuration example: Configuration example:
{ 'id' : 'category_existence', { 'id' : 'category_existence',
......
...@@ -31,9 +31,9 @@ from Constraint import Constraint ...@@ -31,9 +31,9 @@ from Constraint import Constraint
class CategoryMembershipArity(Constraint): class CategoryMembershipArity(Constraint):
""" """
This method check and fix if an object respects the arity. This constraint checks if an object respects the arity.
For example we can check if every Order has at
least one source. For example we can check if every Order has at least one source.
Configuration exemple: Configuration exemple:
{ 'id' : 'source', { 'id' : 'source',
'description' : '', 'description' : '',
...@@ -45,6 +45,7 @@ class CategoryMembershipArity(Constraint): ...@@ -45,6 +45,7 @@ class CategoryMembershipArity(Constraint):
'condition' : 'python: object.getPortalType() == 'Foo', 'condition' : 'python: object.getPortalType() == 'Foo',
}, },
""" """
_message_id_list = ['message_arity_too_small', _message_id_list = ['message_arity_too_small',
'message_arity_not_in_range', 'message_arity_not_in_range',
'message_arity_with_portal_type_to_small', 'message_arity_with_portal_type_to_small',
...@@ -73,9 +74,7 @@ class CategoryMembershipArity(Constraint): ...@@ -73,9 +74,7 @@ class CategoryMembershipArity(Constraint):
portal_type=portal_type)) portal_type=portal_type))
def checkConsistency(self, obj, fixit=0): def checkConsistency(self, obj, fixit=0):
""" """Check the object's consistency.
This is the check method, we return a list of string,
each string corresponds to an error.
We are looking the definition of the constraing where We are looking the definition of the constraing where
are defined the minimum and the maximum arity, and the are defined the minimum and the maximum arity, and the
list of objects we wants to check the arity. list of objects we wants to check the arity.
......
...@@ -51,12 +51,7 @@ class CategoryMembershipState(Constraint): ...@@ -51,12 +51,7 @@ class CategoryMembershipState(Constraint):
"which is not in ${valid_state_list}" "which is not in ${valid_state_list}"
def checkConsistency(self, obj, fixit=0): def checkConsistency(self, obj, fixit=0):
""" """Check the object's consistency.
This is the check method, we return a list of string,
each string corresponds to an error.
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): if not self._checkConstraintCondition(obj):
return [] return []
...@@ -64,7 +59,7 @@ class CategoryMembershipState(Constraint): ...@@ -64,7 +59,7 @@ class CategoryMembershipState(Constraint):
# Retrieve values inside de PropertySheet (_constraints) # Retrieve values inside de PropertySheet (_constraints)
base_category = self.constraint_definition['base_category'] base_category = self.constraint_definition['base_category']
portal_type = self.constraint_definition['portal_type'] portal_type = self.constraint_definition['portal_type']
membership_list = obj.getValueList(base_category, membership_list = obj.getValueList(base_category,
portal_type=portal_type) portal_type=portal_type)
state_var_list = self.constraint_definition.copy() state_var_list = self.constraint_definition.copy()
state_var_list.pop('portal_type') state_var_list.pop('portal_type')
......
...@@ -33,8 +33,9 @@ from Products.ERP5Type.Constraint.CategoryMembershipArity \ ...@@ -33,8 +33,9 @@ from Products.ERP5Type.Constraint.CategoryMembershipArity \
class CategoryRelatedMembershipArity(CategoryMembershipArity): class CategoryRelatedMembershipArity(CategoryMembershipArity):
""" """
This method check and fix if an object respects the arity This method checks if an object respects the arity from a category reverse
from a category reverse membership point of view. membership point of view.
For example we can check if every Order has at For example we can check if every Order has at
most one Order Applied Rule. most one Order Applied Rule.
Configuration example: Configuration example:
......
...@@ -61,9 +61,7 @@ class PortalTypeClass(Constraint): ...@@ -61,9 +61,7 @@ class PortalTypeClass(Constraint):
" document class is ${document_class}" " document class is ${document_class}"
def checkConsistency(self, obj, fixit=0): def checkConsistency(self, obj, fixit=0):
""" """Check the object's consistency.
This is the check method, we return a list of string,
each string corresponds to an error.
""" """
if not self._checkConstraintCondition(obj): if not self._checkConstraintCondition(obj):
return [] return []
......
...@@ -31,8 +31,8 @@ from Constraint import Constraint ...@@ -31,8 +31,8 @@ from Constraint import Constraint
class PropertyExistence(Constraint): class PropertyExistence(Constraint):
""" """
This method check and fix if an object respects the existence of a This method checks if an object respects the existence of a property.
property.
For example we can check if every invoice line has a price defined For example we can check if every invoice line has a price defined
on it. on it.
Configuration example: Configuration example:
...@@ -52,9 +52,7 @@ class PropertyExistence(Constraint): ...@@ -52,9 +52,7 @@ class PropertyExistence(Constraint):
"${property_id}, this property is not defined" "${property_id}, this property is not defined"
def checkConsistency(self, obj, fixit=0): def checkConsistency(self, obj, fixit=0):
""" """Check the object's consistency.
This is the check method, we return a list of string,
each string corresponds to an error.
""" """
if not self._checkConstraintCondition(obj): if not self._checkConstraintCondition(obj):
return [] return []
......
...@@ -79,9 +79,7 @@ class PropertyTypeValidity(Constraint): ...@@ -79,9 +79,7 @@ class PropertyTypeValidity(Constraint):
def checkConsistency(self, obj, fixit=0): def checkConsistency(self, obj, fixit=0):
""" """Check the object's consistency.
This is the check method, we return a list of string,
each string corresponds to an error.
""" """
error_list = [] error_list = []
# For each attribute name, we check type # For each attribute name, we check type
......
...@@ -31,9 +31,9 @@ from Products.ERP5Type.Constraint.PropertyExistence import PropertyExistence ...@@ -31,9 +31,9 @@ from Products.ERP5Type.Constraint.PropertyExistence import PropertyExistence
class StringAttributeMatch(PropertyExistence): class StringAttributeMatch(PropertyExistence):
""" """
This constraint class allows to check This constraint class allows to check that a string property matches a
that a string property match a regular regular expression.
expression. Configuration example: Configuration example:
{ 'id' : 'title_not_empty', { 'id' : 'title_not_empty',
'description' : 'Title must be defined', 'description' : 'Title must be defined',
'type' : 'StringAttributeMatch', 'type' : 'StringAttributeMatch',
...@@ -48,10 +48,8 @@ class StringAttributeMatch(PropertyExistence): ...@@ -48,10 +48,8 @@ class StringAttributeMatch(PropertyExistence):
"${attribute_value} and does not match ${regular_expression}." "${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.
This is the check method, we return a list of string, Check that each attribute matches the regular expression.
each string corresponds to an error.
Check that each attribute does not match the RE
""" """
error_list = PropertyExistence.checkConsistency( error_list = PropertyExistence.checkConsistency(
self, object, fixit=fixit) self, object, fixit=fixit)
......
...@@ -59,7 +59,8 @@ class TALESConstraint(Constraint): ...@@ -59,7 +59,8 @@ class TALESConstraint(Constraint):
"Error while evaluating expression: ${error_text}" "Error while evaluating expression: ${error_text}"
def checkConsistency(self, obj, fixit=0): def checkConsistency(self, obj, fixit=0):
"""See Interface """ """Check the object's consistency.
"""
# import this later to prevent circular import # import this later to prevent circular import
from Products.ERP5Type.Utils import createExpressionContext from Products.ERP5Type.Utils import createExpressionContext
if not self._checkConstraintCondition(obj): if not self._checkConstraintCondition(obj):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment