ORIONIS API REFERENCE

THE ORIONIS API

Build with clarity.

Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.

class documentation

class SessionManager: (source)

Constructor: SessionManager(app, cache)

View In Hierarchy

Coordinate the session lifecycle for every HTTP request.

This class is a coordinator only. It never stores session data, never interprets the session payload, and never duplicates logic that belongs to Session or to the backing store.

Parameters
appApplication providing session configuration and filesystem paths.
cacheCache manager used when the configured session store is cache-backed.
Method __deleteCookie Set an expired cookie to instruct the browser to clear it.
Method __init__ Initialise the manager, pre-computing all request-invariant values.
Async Method __invalidateSession Remove the session record and expire the cookie on response.
Async Method __persist Write the current session state to the backing store.
Method __register Register the session in the application container.
Method __resolveStore Resolve and return the configured session store implementation.
Async Method __restore Load a session from the store, or return a blank lazy session.
Async Method __rotateId Replace the session ID, deleting the old record from the store.
Method __setCookie Attach the session identifier cookie to response.
Async Method abort Persist pending revocation when a request cannot produce a response.
Async Method save Persist the session and set the cookie on response.
Async Method start Restore or create a session for the incoming request.
Class Variable __slots__ Declare the instance attribute slots reserved by this class.
Instance Variable _app The application instance.
Instance Variable _cookie_domain Cookie domain obtained from config.domain.
Instance Variable _cookie_http_only Cookie http only obtained from config.http_only.
Instance Variable _cookie_max_age Lifetime applied to the session cookie.
Instance Variable _cookie_name Cookie name obtained from config.cookie.
Instance Variable _cookie_partitioned Cookie partitioned obtained from config.partitioned.
Instance Variable _cookie_path Cookie path obtained from config.path.
Instance Variable _cookie_same_site Cookie same site produced by getattr.
Instance Variable _cookie_secure Cookie secure obtained from config.secure.
Instance Variable _lifetime_delta Lifetime delta produced by timedelta.
Instance Variable _renewal_delta Interval used to calculate the next session renewal deadline.
Instance Variable _renewal_window Window during which a session becomes eligible for renewal.
Instance Variable _store Pre-built backing-store instance.
Instance Variable _track_previous_url Track previous url obtained from config.track_previous_url.
Property tracksPreviousUrl Return whether session middleware remembers successful navigation URLs.
def __deleteCookie(self, response: _http.Response): (source)

Set an expired cookie to instruct the browser to clear it.

Parameters
response:orionis.http.ResponseThe outgoing response.
Returns
NoneNo return value.
def __init__(self, app: IApplication, cache: ICacheManager): (source)

Initialise the manager, pre-computing all request-invariant values.

Parameters
app:orionis.IApplicationThe application instance.
cache:orionis.cache.contracts.ICacheManagerThe application's cache manager, injected so the cache-backed store can be built without depending on the Cache facade's pin state.
Returns
NoneNo return value.
async def __invalidateSession(self, response: _http.Response, session: Session): (source)

Remove the session record and expire the cookie on response.

Parameters
response:orionis.http.ResponseResponse on which the expired cookie is set.
session:orionis.session.session.SessionThe session to remove.
Returns
NoneNo return value.
async def __persist(self, session: Session) -> bool: (source)

Write the current session state to the backing store.

Parameters
session:orionis.session.session.SessionThe session to persist. session.id must not be None.
Returns
boolFalse if a restored session has already been revoked or expired.
def __register(self, session: Session): (source)

Register the session in the application container.

Parameters
session:orionis.session.session.SessionThe session to register.
Returns
NoneNo return value.
def __resolveStore(self, base_path: Path, config: SessionConfig, cache: ICacheManager) -> ISessionStore: (source)

Resolve and return the configured session store implementation.

Parameters
base_path:pathlib.PathBase project path used to resolve file-store directories.
config:orionis.foundation.config.session.SessionSession configuration containing the selected driver.
cache:orionis.cache.contracts.ICacheManagerThe application's cache manager, used by the cache driver.
Returns
orionis.session.contracts.ISessionStoreStore implementing the selected file, cache, database or memory driver.
async def __restore(self, session_id: str) -> Session: (source)

Load a session from the store, or return a blank lazy session.

The store is trusted to handle expiry: a None return means the record was absent or already expired.

Parameters
session_id:strThe identifier read from the session cookie.
Returns
orionis.session.session.SessionRestored session, or a blank lazy session on cache miss.
async def __rotateId(self, session: Session) -> bool: (source)

Replace the session ID, deleting the old record from the store.

Parameters
session:orionis.session.session.SessionThe session whose ID is to be rotated.
Returns
boolFalse if another request has already invalidated the old ID.
def __setCookie(self, response: _http.Response, session_id: str, *, expired: bool = False): (source)

Attach the session identifier cookie to response.

Parameters
response:orionis.http.ResponseThe outgoing response.
session_id:strThe session identifier to embed in the cookie value.
expired:bool, optionalWhether to expire the cookie while preserving its configured policy.
Returns
NoneNo return value.
async def abort(self, session: Session): (source)

Persist pending revocation when a request cannot produce a response.

Parameters
session:orionis.session.session.SessionSession belonging to a failed or cancelled request.
Returns
NoneNo return value.
async def save(self, response: _http.Response, session: Session): (source)

Persist the session and set the cookie on response.

No-op when the session was never activated. With a renewal interval, unchanged scalar payloads retain their existing store and cookie expiry until the deadline; mutable payloads are always persisted. Browser session cookies still omit Max-Age when expire_on_close is enabled.

Parameters
response:orionis.http.ResponseOutgoing HTTP response.
session:orionis.session.session.SessionThe session returned by start().
Returns
NoneNo return value.
async def start(self, request: _http.Request) -> Session: (source)

Restore or create a session for the incoming request.

Parameters
request:orionis.http.RequestThe incoming HTTP request.
Returns
orionis.session.session.SessionAn active or blank lazy session, with flash data aged.
__slots__: tuple[str, ...] = (source)

Declare the instance attribute slots reserved by this class.

The application instance.

_cookie_domain: str | None = (source)

Cookie domain obtained from config.domain.

_cookie_http_only: bool = (source)

Cookie http only obtained from config.http_only.

_cookie_max_age: int | None = (source)

Lifetime applied to the session cookie.

_cookie_name: str = (source)

Cookie name obtained from config.cookie.

_cookie_partitioned: bool = (source)

Cookie partitioned obtained from config.partitioned.

_cookie_path: str = (source)

Cookie path obtained from config.path.

_cookie_same_site: str = (source)

Cookie same site produced by getattr.

_cookie_secure: bool = (source)

Cookie secure obtained from config.secure.

_lifetime_delta: timedelta = (source)

Lifetime delta produced by timedelta.

_renewal_delta = (source)

Interval used to calculate the next session renewal deadline.

_renewal_window = (source)

Window during which a session becomes eligible for renewal.

_store: ISessionStore = (source)

Pre-built backing-store instance.

_track_previous_url = (source)

Track previous url obtained from config.track_previous_url.

tracksPreviousUrl: bool = (source)

Return whether session middleware remembers successful navigation URLs.

Returns
boolWhether previous-page tracking is enabled for this manager.