core.browser_session

Attributes

OnDirtyCallback

_T

Classes

Prefixed

BrowserSession

A session bound to a token (session_id cookie). Used to store data

Module Contents

core.browser_session.OnDirtyCallback[source]
core.browser_session._T[source]
class core.browser_session.Prefixed(prefix: str, cache: core.cache.RedisCacheRegion)[source]
mangle(key: str) str[source]
get(key: str) Any[source]
set(key: str, value: Any) None[source]
delete(key: str) None[source]
count() int[source]
flush() int[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_session to 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.

has(name: str) bool[source]
flush() None[source]
count() int[source]
pop(name: str, default: Any = None) Any[source]

Returns the value for the given name, removing the value in the process.

mark_as_dirty() None[source]
get(name: str) Any | None[source]
get(name: str, default: _T) Any | _T
__getitem__(name: str, *args: typing_extensions.Never) Any[source]
__getattr__(name: str) Any[source]
__setattr__(name: str, value: Any) None[source]

Implement setattr(self, name, value).

__delattr__(name: str) None[source]

Implement delattr(self, name).

__setitem__[source]
__delitem__[source]
__delattr__[source]
__contains__[source]