Merge pull request #160 from Ankhbayar/master

Added __hash__, __ne__ with test. 
Thanks Ankhbayar
This commit is contained in:
Ross Lawley
2011-05-09 02:28:41 -07:00
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):