[CalendarServer-changes] [5564] CalendarServer/branches/users/wsanchez/transations/txdav/ propertystore/base.py
source_changes at macosforge.org
source_changes at macosforge.org
Tue May 4 17:01:01 PDT 2010
Revision: 5564
http://trac.macosforge.org/projects/calendarserver/changeset/5564
Author: glyph at apple.com
Date: 2010-05-04 17:00:59 -0700 (Tue, 04 May 2010)
Log Message:
-----------
Proper comparison operations.
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/transations/txdav/propertystore/base.py
Modified: CalendarServer/branches/users/wsanchez/transations/txdav/propertystore/base.py
===================================================================
--- CalendarServer/branches/users/wsanchez/transations/txdav/propertystore/base.py 2010-05-04 23:59:03 UTC (rev 5563)
+++ CalendarServer/branches/users/wsanchez/transations/txdav/propertystore/base.py 2010-05-05 00:00:59 UTC (rev 5564)
@@ -49,9 +49,31 @@
self.namespace = namespace
self.name = name
+
+ def _cmpval(self):
+ """
+ Return a value to use for hashing and comparisons.
+ """
+ return (self.namespace, self.name)
+
+
+ # FIXME: need direct tests for presence-in-dictionary
def __hash__(self):
- return hash((self.namespace, self.name))
+ return hash(self._cmpval())
+
+ def __eq__(self, other):
+ if not isinstance(other, PropertyName):
+ return NotImplemented
+ return self._cmpval() == other._cmpval()
+
+
+ def __ne__(self, other):
+ if not isinstance(other, PropertyName):
+ return NotImplemented
+ return self._cmpval() != other._cmpval()
+
+
def __repr__(self):
return "<%s: %s>" % (
self.__class__.__name__,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100504/1367245e/attachment.html>
More information about the calendarserver-changes
mailing list