From d8d85815adf45f1ff0842f816f3b827b69d5a4c0 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Sat, 13 Oct 2012 09:26:53 -0500 Subject: [PATCH] redis session patch, thanks Niphlod --- VERSION | 2 +- gluon/contrib/redis_session.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index a89ca156..142289f4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.1.0 (2012-10-13 09:25:28) dev +Version 2.1.0 (2012-10-13 09:26:50) dev diff --git a/gluon/contrib/redis_session.py b/gluon/contrib/redis_session.py index f675313e..e8bacfcd 100644 --- a/gluon/contrib/redis_session.py +++ b/gluon/contrib/redis_session.py @@ -19,8 +19,8 @@ locker = thread.allocate_lock() def RedisSession(*args, **vars): """ Usage example: put in models - - sessiondb = RedisSession('localhost:6379',db=0, debug=True) + from gluon.contrib.redis_session import RedisSession + sessiondb = RedisSession('localhost:6379',db=0, session_expiry=False) session.connect(request, response, db = sessiondb) Simple slip-in storage for session @@ -180,7 +180,10 @@ class MockQuery(object): def update(self, **kwargs): #means that the session has been found and needs an update if self.op == 'eq' and self.field == 'id' and self.value: - return self.db.hmset("%s:%s" % (self.keyprefix, self.value), kwargs) + rtn = self.db.hmset("%s:%s" % (self.keyprefix, self.value), kwargs) + if self.session_expiry: + self.db.expire(key, self.session.expiry) + return rtn class RecordDeleter(object): """Dumb record deleter to support sessions2trash.py"""