Commit 912b114a authored by Yoshinori Okuji's avatar Yoshinori Okuji

Make the identity check insensitive to the order of a list.

Also, simplify the check code.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@803 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e5d17126
...@@ -68,13 +68,18 @@ class AttributeEquality(Constraint): ...@@ -68,13 +68,18 @@ class AttributeEquality(Constraint):
error_message = None error_message = None
if not object.hasProperty(attribute_name): if not object.hasProperty(attribute_name):
error_message = "Attribute %s is not defined" % attribute_name error_message = "Attribute %s is not defined" % attribute_name
elif type(attribute_value) is type([]) or type(attribute_value) is type(()): else:
if list(object.getProperty(attribute_name)) != list(attribute_value): identical = 1
if len(object.getProperty(attribute_name)) != len(attribute_value):
identical = 0
else:
for item in object.getProperty(attribute_name):
if item not in attribute_value:
identical = 0
break
if not identical:
error_message = "Attribute %s is %s but sould be %s" % (attribute_name, error_message = "Attribute %s is %s but sould be %s" % (attribute_name,
object.getProperty(attribute_name), attribute_value) object.getProperty(attribute_name), attribute_value)
elif object.getProperty(attribute_name) != attribute_value:
error_message = "Attribute %s is %s but sould be %s" % (attribute_name,
object.getProperty(attribute_name), attribute_value)
if error_message is not None: if error_message is not None:
if fixit: if fixit:
object._setProperty(attribute_name, attribute_value) object._setProperty(attribute_name, attribute_value)
......
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