Exemplo n.º 1
0
 def __iter__(self):
     """
     override __iter__ to pull results from dogpile
     if particular attributes have been configured.
     """
     if hasattr(self, '_cache_region'):
         return self.get_value(createfunc=lambda: list(BaseQuery.__iter__(self)))
     else:
         return BaseQuery.__iter__(self)
Exemplo n.º 2
0
 def __iter__(self):
     """
     override __iter__ to pull results from dogpile
     if particular attributes have been configured.
     """
     if hasattr(self, '_cache_region'):
         return self.get_value(
             createfunc=lambda: list(BaseQuery.__iter__(self)))
     else:
         return BaseQuery.__iter__(self)
Exemplo n.º 3
0
    def __iter__(self):
        """override __iter__ to pull results from dogpile if particular attributes have been configured.

        Note that this approach does NOT detach the loaded objects from the current session. If the cache backend
        is an in-process cache (like "memory") and lives beyond the scope of the current session's transaction,
        those objects may be expired. The method here can be modified to first expunge() each loaded item from the
        current session before returning the list of items, so that the items in the cache are not the same ones
        in the current session.
        """
        if hasattr(self, '_cache_region'):
            return self.get_value(
                createfunc=lambda: list(BaseQuery.__iter__(self)))
        else:
            return BaseQuery.__iter__(self)
Exemplo n.º 4
0
    def __iter__(self):
        """
        Override __iter__ to pull results from cache if particular
        attributes have been configured.

        This approach does *not* detach the loaded objects from the current
        session. If the cache backend is an in-process cache (like "memory")
        and lives beyond the scope of the current session's transaction, those
        objects may be expired.

        The method here can be modified to first expunge() each loaded item
        from the current session before returning the list of items, so that
        the items in the cache are not the same ones in the current Session.
        """
        if hasattr(self, '_cache'):
            func = lambda: list(BaseQuery.__iter__(self))
            return iter(self.get_value(createfunc=func))
        else:
            return BaseQuery.__iter__(self)
Exemplo n.º 5
0
 def __iter__(self):
     if hasattr(self, '_cache_region'):
         return self.get_value(
             createfunc=lambda: list(BaseQuery.__iter__(self)))
     else:
         return BaseQuery.__iter__(self)
Exemplo n.º 6
0
 def create_func():
     return list(BaseQuery.__iter__(self))
 def __iter__(self):
     return BaseQuery.__iter__(self.private())
Exemplo n.º 8
0
 def __iter__(self):
     return QueryClass.__iter__(self._undeleted())