Commit 1e9848e0 authored by Arnaud Fontaine's avatar Arnaud Fontaine

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



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41824 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 351e080e
...@@ -57,26 +57,29 @@ class PropertyExistenceConstraint(ConstraintMixin): ...@@ -57,26 +57,29 @@ class PropertyExistenceConstraint(ConstraintMixin):
property_sheets = ConstraintMixin.property_sheets + \ property_sheets = ConstraintMixin.property_sheets + \
(PropertySheet.PropertyExistenceConstraint,) (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. Check the object's consistency.
""" """
error_list = [] error_list = []
# For each attribute name, we check if defined # For each attribute name, we check if defined
for property_id in self.getConstraintPropertyList(): for property_id in self.getConstraintPropertyList():
# Check existence of property error_message_id = self._checkPropertyConsistency(obj, property_id)
mapping = dict(property_id=property_id) if error_message_id is not None:
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_list.append(self._generateError( 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 return error_list
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