From 912b114a9f4605468e064fb7aaedfaa85074c5ee Mon Sep 17 00:00:00 2001 From: Yoshinori Okuji <yo@nexedi.com> Date: Mon, 3 May 2004 11:46:18 +0000 Subject: [PATCH] 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 --- .../ERP5Type/Constraint/AttributeEquality.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/product/ERP5Type/Constraint/AttributeEquality.py b/product/ERP5Type/Constraint/AttributeEquality.py index 896b520e2a..8288049b26 100755 --- a/product/ERP5Type/Constraint/AttributeEquality.py +++ b/product/ERP5Type/Constraint/AttributeEquality.py @@ -68,13 +68,18 @@ 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): + 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) - 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) + object.getProperty(attribute_name), attribute_value) if error_message is not None: if fixit: object._setProperty(attribute_name, attribute_value) -- 2.30.9