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):
Check that each attribute does not match the RE
"""
errors = PropertyExistence.checkConsistency(self, object, 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.
current_value = object.getProperty(attribute_name)
regexp = re.compile(attribute_value)
if (current_value is not None) and \
(regexp.match(current_value) is None):
# Generate error_message
error_message = "Attribute %s is '%s' and not match '%s'" % \
(attribute_name, current_value,
attribute_value)
# Generate error
errors.append(self._generateError(object, error_message))
if not errors:
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.
current_value = object.getProperty(attribute_name)
regexp = re.compile(attribute_value)
if (current_value is not None) and \
(regexp.match(current_value) is None):
# Generate error_message
error_message = "Attribute %s is '%s' and not match '%s'" % \
(attribute_name, current_value,
attribute_value)
# Generate error
errors.append(self._generateError(object, error_message))
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