Example #1
0
    def __init__(self, model_class):
        self.model_class = model_class
        self.key = model_class._key
        # We access directly _meta as .db is a property and should be
        # access from an instance, not a Class
        self._db = model_class._meta["db"] or modelplus.get_db()
        self._filters = {}
        self._exclusions = {}
        self._ordering = []
        self._limit = None
        self._offset = None

        # Insure that we've done any necessary DB work to make this class happen
        self.db.construct(model_class._key)
Example #2
0
 def exists(cls, id):
     """Checks if the model with id exists."""
     return bool((cls._meta['db'] or modelplus.get_db()).exists(cls._key[str(id)]))
Example #3
0
 def setUp(self):
     self.client = modelplus.get_db()
     self.client.flushdb()
Example #4
0
 def db(self):
     """Returns the Redis client used by the model."""
     return modelplus.get_db() if not self._meta['db'] else self._meta['db']