예제 #1
0
 def _add_set_exclusions(self, s):
     indices = []
     for k, v in self._exclusions.iteritems():
         index = self._build_key_from_filter_item(k, v)
         if k not in self.model_class._indices:
             raise AttributeNotIndexed(
                 "Attribute %s is not indexed in %s class." %
                 (k, self.model_class.__name__))
         indices.append(index)
     new_set_key = "~%s.%s" % ("-".join([self.key] + indices), id(self))
     s.difference(new_set_key, *[Set(n) for n in indices])
     self._expire_or_delete.append(new_set_key)
     return Set(new_set_key)
예제 #2
0
    def _add_set_exclusions(self, s):
        """
        This function is the internals of the `filter` function.
        It simply creates a new "difference" of indexed keys (the filter) and
        the previous filtered keys (if any).

        .. Note:: This function uses the ``Set`` container class.

        :return: the new Set
        """
        indices = []
        for k, v in self._exclusions.iteritems():
            index = self._build_key_from_filter_item(k, v)
            if k not in self.model_class._indices:
                raise AttributeNotIndexed(
                        "Attribute %s is not indexed in %s class." %
                        (k, self.model_class.__name__))
            indices.append(index)
        new_set_key = "~%s.%s" % ("-".join([self.key] + indices), id(self))
        s.difference(new_set_key, *[Set(n, db=self.db) for n in indices])
        new_set = Set(new_set_key, db=self.db)
        new_set.set_expire()
        return new_set