示例#1
0
    def select_related(self, max_depth=1):
        """Handles dereferencing of :class:`~pymongo.dbref.DBRef` objects to
        a maximum depth in order to cut down the number queries to mongodb.

        .. versionadded:: 0.5
        """
        from dereference import dereference
        self._data = dereference(self._data, max_depth)
        return self
示例#2
0
    def select_related(self, max_depth=1):
        """Handles dereferencing of :class:`~pymongo.dbref.DBRef` objects to
        a maximum depth in order to cut down the number queries to mongodb.

        .. versionadded:: 0.5
        """
        from dereference import dereference
        self._data = dereference(self._data, max_depth)
        return self
示例#3
0
    def __get__(self, instance, owner):
        """Descriptor to automatically dereference references.
        """
        if instance is None:
            # Document class being used rather than a document object
            return self

        from dereference import dereference
        instance._data[self.name] = dereference(
            instance._data.get(self.name), max_depth=1, instance=instance, name=self.name, get=True
        )
        return super(ComplexBaseField, self).__get__(instance, owner)
示例#4
0
    def __get__(self, instance, owner):
        """Descriptor to automatically dereference references.
        """
        if instance is None:
            # Document class being used rather than a document object
            return self

        from dereference import dereference
        instance._data[self.name] = dereference(
            instance._data.get(self.name), max_depth=1, instance=instance, name=self.name, get=True
        )
        return super(ComplexBaseField, self).__get__(instance, owner)
示例#5
0
 def select_related(self, max_depth=1):
     from dereference import dereference
     self._data = dereference(self._data, max_depth)
     return self