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): ...@@ -68,11 +68,16 @@ 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
error_message = "Attribute %s is %s but sould be %s" % (attribute_name, if len(object.getProperty(attribute_name)) != len(attribute_value):
object.getProperty(attribute_name), attribute_value) identical = 0
elif object.getProperty(attribute_name) != attribute_value: 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)
if error_message is not None: 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