From 1e7fa943befd42a49d24125216e362ea6e97b6d6 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Wed, 28 Apr 2010 21:52:40 +0200 Subject: [PATCH] Add hash function to models --- mopidy/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mopidy/models.py b/mopidy/models.py index c02babce..5f61f019 100644 --- a/mopidy/models.py +++ b/mopidy/models.py @@ -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): """