Skip to content

Session Module

session related module

Session()

Base class for objects covers data related to a server side session.

SessionContext

clear() classmethod

delete the current session

get(type) classmethod

return the current session associated with the context Args: type: the session type

Returns:

Type Description
T

the current session

set(session) classmethod

set the current session in the context Args: session: the session

SessionManager(storage)

Bases: SessionContext

A SessionManager controls the lifecycle of sessions and is responsible to establish a session context local.

InMemoryStorage(max_size=1000, ttl=3600)

Bases: Storage

InMemoryStorage is a simple in-memory storage for sessions. It uses a TTLCache to store sessions with a time-to-live.

create_session(*args, **kwargs)

create a session given the arguments (usually a token, etc.) Args: args: rest args kwargs: keyword args

Returns:

Type Description
Session

the new session

set_factory(factory)

set a factory function that will be used to create a concrete session Args: factory: the function