Add hash function to models

This commit is contained in:
Thomas Adamcik 2010-04-28 21:52:40 +02:00
parent 3c36efad5d
commit 1e7fa943be

View File

@ -17,6 +17,12 @@ class ImmutableObject(object):
return super(ImmutableObject, self).__setattr__(name, value)
raise AttributeError('Object is immutable.')
def __hash__(self):
sum = 0
for key,value in self.__dict__.items():
sum += hash(key) + hash(value)
return sum
class Artist(ImmutableObject):
"""