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,11 +68,16 @@ class AttributeEquality(Constraint):
error_message = None
if not object.hasProperty(attribute_name):
error_message = "Attribute %s is not defined" % attribute_name
elif type(attribute_value) is type([]) or type(attribute_value) is type(()):
if list(object.getProperty(attribute_name)) != list(attribute_value):
error_message = "Attribute %s is %s but sould be %s" % (attribute_name,
object.getProperty(attribute_name), attribute_value)
elif object.getProperty(attribute_name) != attribute_value:
else:
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,
object.getProperty(attribute_name), attribute_value)
if error_message is not None:
......
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