Added select_related() and refactored dereferencing

Added a dereference class to handle both select_related
 / recursive dereferencing and fetching dereference.

Refs #206
This commit is contained in:
Ross Lawley
2011-06-22 15:45:25 +01:00
parent 14be7ba2e2
commit 87f486c4f1
6 changed files with 459 additions and 80 deletions

View File

@@ -193,6 +193,11 @@ class Document(BaseDocument):
signals.post_delete.send(self.__class__, document=self)
def select_related(self, max_depth=1):
from dereference import dereference
self._data = dereference(self._data, max_depth)
return self
def reload(self):
"""Reloads all attributes from the database.