From 90d9bd9723afae25b084c376d56725e9296a33a9 Mon Sep 17 00:00:00 2001 From: Deepak Thukral Date: Sun, 21 Feb 2010 12:13:58 +0100 Subject: [PATCH] added natural object comparision --- mongoengine/base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mongoengine/base.py b/mongoengine/base.py index d2eced9e..a452f3c8 100644 --- a/mongoengine/base.py +++ b/mongoengine/base.py @@ -388,3 +388,9 @@ class BaseDocument(object): obj = cls(**data) obj._present_fields = present_fields return obj + + def __eq__(self, other): + assert hasattr(other, 'id'), "You cannot compare two objects of different type." + if self.id == other.id: + return True + return False