Permalink
Browse files

Fixing dereferencing when the dereferenced-document wasn't found.

  • Loading branch information...
1 parent adb7bbe commit c081aca79431e7e060e66c2e4d4da88cc66ed8ae Karim Allah committed Sep 25, 2011
Showing with 4 additions and 0 deletions.
  1. +4 −0 mongoengine/base.py
View
@@ -10,6 +10,7 @@
import pymongo.objectid
import operator
from functools import partial
+from bson.dbref import DBRef
class NotRegistered(Exception):
@@ -97,6 +98,9 @@ def __get__(self, instance, owner):
# Get value from document instance if available, if not use default
value = instance._data.get(self.name)
+ if isinstance(value, DBRef):
+ raise ValueError("Can't dereference from the given DBRef (%s)" % str(value))
+
if value is None:
value = self.default
# Allow callable default values

0 comments on commit c081aca

Please sign in to comment.