diff --git a/mongoengine/__init__.py b/mongoengine/__init__.py index 0feb49e08..152fea8c2 100644 --- a/mongoengine/__init__.py +++ b/mongoengine/__init__.py @@ -23,7 +23,7 @@ list(signals.__all__) + list(errors.__all__)) -VERSION = (0, 12, 0) +VERSION = (0, 12, 0, 1, "fbx_warn_hack") def get_version(): diff --git a/mongoengine/base/document.py b/mongoengine/base/document.py index ce96837aa..4c0781e10 100644 --- a/mongoengine/base/document.py +++ b/mongoengine/base/document.py @@ -272,7 +272,11 @@ def __eq__(self, other): def __ne__(self, other): return not self.__eq__(other) - def __hash__(self): + def __hash__(self, warn=True): + if warn: + from fundbox.common.logging import get_logger + import traceback + get_logger().warn("mongoenging cannot hash obj {} class {}\n{}".format(self, self.__class__.__name__, "".join(traceback.format_stack()))) if getattr(self, 'pk', None) is None: # For new object return super(BaseDocument, self).__hash__() diff --git a/mongoengine/document.py b/mongoengine/document.py index b79e5e976..a0bedff20 100644 --- a/mongoengine/document.py +++ b/mongoengine/document.py @@ -148,6 +148,9 @@ class Document(BaseDocument): __slots__ = ('__objects',) + def __hash__(self): + return super(Document, self).__hash__(warn=False) + @property def pk(self): """Get the primary key."""