A simple in-memory volatile session store, mimicking the default Quixote session management. Here for example’s sake only…
from SessionStore import SessionStoreA simple volatile (non-persistent) session store for session3.
class VolatileSessionStore(SessionStore):
is_multiprocess_safe = True
is_thread_safe = TrueCreate the dictionary.
def __init__(self):
self.sessions = {}Return the session if it exists, else return ‘default’.
def load_session(self, id, default=None):
return self.sessions.get(id, default)Save the session in the dictionary..
def save_session(self, session):
self.sessions[session.id] = sessionDelete the session in the dictionary.
def delete_session(self, session):
if session.id in self.sessions:
del self.sessions[session.id]Return true if the session exists in the dictionary, else false.
def has_session(self, id):
return id in self.sessions