Example #1
0
 def update(self):
     """
     Updates the internal list of objects, stored in a couch list, deleting
     keys that no longer exist, and adding new keys that are not currently
     part of the collection.
     """
     keys = [ item.id for item in self.model.getAll(self._view, self.userID) ]
     self.pail = brm.redisList(self.pattern, keys, reset=True)
Example #2
0
 def update(self):
     """
     Updates the internal list of objects, stored in a Redis list, deleting
     keys that no longer exist, and adding new keys that are not currently
     part of the collection.
     """
     key = self.pattern.split(":")[0]
     setPail = list(set([ key+":"+item.split(":")[1] for item in self.redis.keys(self.pattern) ]))
     self.pail = brm.redisList(key, setPail, reset=True)
Example #3
0
    def __init__(self, model, couch=c.database.couchServer):
        """
        Initializes the object, getting the list of ID's which will result in
        the collection being built when `fetch()` is called.

        :param model: A model which inherits from both `couchdb.Document`
            and `baseCouchModel`
        :param couch: The couchdb instance which this collection should use
        """
        self._collection = []
        self.couch = couch
        self.model = model
        self.pattern = "couch:" + self.model._name
        self.pail = brm.redisList(self.pattern)
        if not self.pail:
            self.update()
Example #4
0
    def __init__(self, pattern, redis=c.database.redisBucketServer):
        """
        Assumes the Redis objects are stored in a pattern of `what:id:parts``
        Where `what` is like a class, where all keys in `what` are of the same
        object type in the system.

        It also assumes that this collection is stored in a redis list under
        the `what` name, so for buckets, the list key would be `bucket`

        :param pattern: The pattern which to find all the keys in this collection
            For example, `bucket:*:value` is a general pattern to find all the ids
            in the category of `bucket`

        :param redis: The Redis instance which this collection should use
        """
        self._collection = []
        self.redis = redis
        self.pattern = pattern
        key = pattern.split(":")[0]
        self.pail = brm.redisList(key)
        if not self.pail:
            self.update()