<commit_before>"""
An :class:`~xblock.runtime.KeyValueStore` that stores data in the django session
"""
from __future__ import absolute_import

from xblock.runtime import KeyValueStore

class SessionKeyValueStore(KeyValueStore):
    def __init__(self, request):
        self._session = request.session

    def get(self, key):
        return self._session[tuple(key)]

    def set(self, key, value):
        self._session[tuple(key)] = value

    def delete(self, key):
        del self._session[tuple(key)]

    def has(self, key):
        return tuple(key) in self._session<commit_msg>Use strings instead of tuples as keys in SessionKeyValueStore<commit_after>"""
An :class:`~xblock.runtime.KeyValueStore` that stores data in the django session
"""
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[stringify(key)]

    def set(self, key, value):
        self._session[stringify(key)] = value

    def delete(self, key):
        del self._session[stringify(key)]

    def has(self, key):
        return stringify(key) in self._session
{'fraction_non_alphanumeric': 0.10318076027928627, 'fraction_numerical': 0.0, 'mean_word_length': 3.7777777777777777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3627565', 'n_tokens_mistral': 376, 'n_tokens_neox': 364, 'n_words': 107}