Encode/decode redis data which expects bytes

This commit is contained in:
Guewen Baconnier
2017-11-15 16:25:02 +01:00
parent ea44b4fd15
commit 207cd6504c
+3 -2
View File
@@ -47,7 +47,8 @@ class RedisSessionStore(SessionStore):
"expiration of %s seconds for %s", "expiration of %s seconds for %s",
key, self.expiration, user_msg) key, self.expiration, user_msg)
if self.redis.set(key, json.dumps(dict(session))): data = json.dumps(dict(session)).encode('utf-8')
if self.redis.set(key, data):
return self.redis.expire(key, self.expiration) return self.redis.expire(key, self.expiration)
def delete(self, session): def delete(self, session):
@@ -62,7 +63,7 @@ class RedisSessionStore(SessionStore):
return self.new() return self.new()
key = self.build_key(sid) key = self.build_key(sid)
saved = self.redis.get(key) saved = self.redis.get(key).decode('utf-8')
if not saved: if not saved:
_logger.debug("session with non-existent key '%s' has been asked, " _logger.debug("session with non-existent key '%s' has been asked, "
"returning a new one", key) "returning a new one", key)