Commit 8418e446 authored by Romain Courteaud's avatar Romain Courteaud

Do not test attribute if it's not defined.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17173 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4a693974
...@@ -48,18 +48,19 @@ class StringAttributeMatch(PropertyExistence): ...@@ -48,18 +48,19 @@ class StringAttributeMatch(PropertyExistence):
Check that each attribute does not match the RE Check that each attribute does not match the RE
""" """
errors = PropertyExistence.checkConsistency(self, object, fixit=fixit) errors = PropertyExistence.checkConsistency(self, object, fixit=fixit)
for attribute_name, attribute_value in self.constraint_definition.items(): if not errors:
error_message = None for attribute_name, attribute_value in self.constraint_definition.items():
# If property does not exist, error will be raise by error_message = None
# PropertyExistence Constraint. # If property does not exist, error will be raise by
current_value = object.getProperty(attribute_name) # PropertyExistence Constraint.
regexp = re.compile(attribute_value) current_value = object.getProperty(attribute_name)
if (current_value is not None) and \ regexp = re.compile(attribute_value)
(regexp.match(current_value) is None): if (current_value is not None) and \
# Generate error_message (regexp.match(current_value) is None):
error_message = "Attribute %s is '%s' and not match '%s'" % \ # Generate error_message
(attribute_name, current_value, error_message = "Attribute %s is '%s' and not match '%s'" % \
attribute_value) (attribute_name, current_value,
# Generate error attribute_value)
errors.append(self._generateError(object, error_message)) # Generate error
errors.append(self._generateError(object, error_message))
return errors return errors
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