@@ -23,6 +23,10 @@ def __eq__(self, obj):
2323 Do a deep comparison of this object and its odml properties.
2424 The 'id' attribute of an object is excluded, since it is
2525 unique within a document.
26+ SmartList attributes of 'sections' and 'properties' are
27+ handled specially: We want to make sure that the lists'
28+ objects are properly compared without changing the order
29+ of the individual lists.
2630 """
2731 # cannot compare totally different stuff
2832 if not isinstance (self , obj .__class__ ):
@@ -31,6 +35,14 @@ def __eq__(self, obj):
3135 for key in self ._format :
3236 if key == "id" or key == "oid" :
3337 continue
38+ elif (isinstance (getattr (self , key ), SmartList ) and
39+ sorted (getattr (self , key ), key = lambda x : x .name ) !=
40+ sorted (getattr (obj , key ), key = lambda x : x .name )):
41+ # This special case was introduced only due to the fact
42+ # that RDF files will be loaded with randomized list
43+ # order. With any other file format the list order
44+ # remains unchanged.
45+ return False
3446 elif getattr (self , key ) != getattr (obj , key ):
3547 return False
3648
0 commit comments