Added __hash__, __ne__ with test.

This commit is contained in:
Анхбаяр Лхагвадорж
2011-04-12 20:23:16 +08:00
parent 69989365c7
commit 96dbeea171
2 changed files with 59 additions and 0 deletions

View File

@@ -489,6 +489,17 @@ class BaseDocument(object):
return True
return False
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
""" For list, dic key """
if self.pk is None:
# For new object
return super(BaseDocument,self).__hash__()
else:
return hash(self.pk)
if sys.version_info < (2, 5):
# Prior to Python 2.5, Exception was an old-style class
def subclass_exception(name, parents, unused):