From a4e0fb34c2d883425602b403948d998c83b7b4ba Mon Sep 17 00:00:00 2001 From: Ricardo Pedroso Date: Sat, 24 Aug 2013 15:33:41 +0100 Subject: [PATCH] support new session logic --- gluon/contrib/redis_session.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gluon/contrib/redis_session.py b/gluon/contrib/redis_session.py index 2d50d35c..b0971551 100644 --- a/gluon/contrib/redis_session.py +++ b/gluon/contrib/redis_session.py @@ -110,6 +110,19 @@ class MockTable(object): self.session_expiry = session_expiry self.with_lock = with_lock + def __call__(self, record_id): + # Support DAL shortcut query: table(record_id) + + q = self.id # This will call the __getattr__ below + # returning a MockQuery + + # Instructs MockQuery, to behave as db(table.id == record_id) + q.op = 'eq' + q.value = record_id + + row = q.select() + return row[0] if row else Storage() + def __getattr__(self, key): if key == 'id': #return a fake query. We need to query it just by id for normal operations @@ -172,6 +185,7 @@ class MockQuery(object): if self.with_lock: acquire_lock(self.db, key + ':lock', self.value) rtn = self.db.hgetall(key) + rtn['update_record'] = self.update # update record support return [Storage(rtn)] if rtn else [] elif self.op == 'ge' and self.field == 'id' and self.value == 0: #means that someone wants the complete list