core.browser_session
Attributes
Classes
A session bound to a token (session_id cookie). Used to store data |
|
Module Contents
- type core.browser_session.OnDirtyCallback = Callable[[BrowserSession, str], None][source]
- class core.browser_session.Prefixed(prefix: str, cache: core.cache.RedisCacheRegion)[source]
- class core.browser_session.BrowserSession(cache: core.cache.RedisCacheRegion, token: str, on_dirty: OnDirtyCallback = lambda session, token: ...)[source]
A session bound to a token (session_id cookie). Used to store data about a client on the server.
Instances should be called
browser_sessionto make sure we don’t confuse this with the orm sessions.Used by
onegov.core.request.CoreRequest.Example:
browser_session = request.browser_session browser_session.name = 'Foo' assert client.session.name == 'Foo' del client.session.name
This class can act like an object, through attribute access, or like a dict, through square brackets. Whatever you prefer.
This class also acts as a data manager for
transaction, so changes are not committed to Redis, until the transaction is commited.The
on_dirtycallback gets invoked when the first change to the session happens, even if it ends up getting rolled back, so use with care!- pop(name: str, default: Any = None) Any[source]
Returns the value for the given name, removing the value in the process.
- savepoint() BrowserSessionSavepoint[source]