Merge pull request #124 from p-tombez/7.0_fix_session_expiration

[7.0] Fix session expiration ignored
This commit is contained in:
Patrick Tombez
2019-12-18 10:56:43 +01:00
committed by GitHub
co-authored by GitHub
+8 -2
View File
@@ -38,14 +38,20 @@ class RedisSessionStore(SessionStore):
def save(self, session):
key = self.build_key(session.sid)
# `session` is the Werkzeug wrapper that contains
# the "real" session object `OpenERPSession`.
# That's why we need to look for the first item in it to get the
# expiration parameter
session_oe = session.itervalues().next()
expiration = getattr(session_oe, 'expiration', self.expiration)
if _logger.isEnabledFor(logging.DEBUG):
_logger.debug("saving session with key '%s' and "
"expiration of %s seconds",
key, self.expiration)
key, expiration)
if self.redis.set(key, dumps(dict(session), HIGHEST_PROTOCOL)):
return self.redis.expire(key, self.expiration)
return self.redis.expire(key, expiration)
def delete(self, session):
key = self.build_key(session.sid)