Commit fc04d8f2 by Carlos Andrés Rocha

Use strings instead of tuples as keys in SessionKeyValueStore

Some Django packages expect only strings as keys in the user session,
and it is also a recommended practice in the Django manual.
parent f94c677a
......@@ -5,18 +5,23 @@ from __future__ import absolute_import
from xblock.runtime import KeyValueStore
def stringify(key):
return repr(tuple(key))
class SessionKeyValueStore(KeyValueStore):
def __init__(self, request):
self._session = request.session
def get(self, key):
return self._session[tuple(key)]
return self._session[stringify(key)]
def set(self, key, value):
self._session[tuple(key)] = value
self._session[stringify(key)] = value
def delete(self, key):
del self._session[tuple(key)]
del self._session[stringify(key)]
def has(self, key):
return tuple(key) in self._session
return stringify(key) in self._session
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment