[Checkins] SVN: lovely.rating/trunk/src/lovely/rating/ compare
ratings explicitly
Bernd Dorn
bernd.dorn at lovelysystems.com
Tue Feb 13 09:56:31 EST 2007
Log message for revision 72512:
compare ratings explicitly
Changed:
U lovely.rating/trunk/src/lovely/rating/README.txt
U lovely.rating/trunk/src/lovely/rating/rating.py
-=-
Modified: lovely.rating/trunk/src/lovely/rating/README.txt
===================================================================
--- lovely.rating/trunk/src/lovely/rating/README.txt 2007-02-13 12:39:53 UTC (rev 72511)
+++ lovely.rating/trunk/src/lovely/rating/README.txt 2007-02-13 14:56:31 UTC (rev 72512)
@@ -151,7 +151,7 @@
>>> ratings = manager.getRatings('usability', dtMin=now-twoDays)
>>> sorted(ratings)
- [<Rating u'Okay' by u'srichter'>, <Rating u'Okay' by u'kartnaller'>]
+ [<Rating u'Okay' by u'kartnaller'>, <Rating u'Okay' by u'srichter'>]
You can also ask for the rating of a particular user:
Modified: lovely.rating/trunk/src/lovely/rating/rating.py
===================================================================
--- lovely.rating/trunk/src/lovely/rating/rating.py 2007-02-13 12:39:53 UTC (rev 72511)
+++ lovely.rating/trunk/src/lovely/rating/rating.py 2007-02-13 14:56:31 UTC (rev 72512)
@@ -40,3 +40,9 @@
def __repr__(self):
return '<%s %r by %r>' %(self.__class__.__name__, self.value, self.user)
+
+ def __cmp__(self, other):
+ if not isinstance(other, Rating):
+ return super(Rating, self).__cmp__(other)
+ return cmp((self.id, self.value, self.user),
+ (other.id, other.value, other.user))
More information about the Checkins
mailing list