duck.http.session.engine¶
Module representing Duck default session engine, i.e. SessionStore class.
Module Contents¶
Classes¶
Session store for storing session data. |
Data¶
API¶
- exception duck.http.session.engine.SessionError[source]¶
Bases:
ExceptionSession related errors.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- exception duck.http.session.engine.SessionExpired[source]¶
Bases:
duck.http.session.engine.SessionErrorRaised on save operations if a session has already expired.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- class duck.http.session.engine.SessionStore(session_key: str, disable_warnings: bool = False)[source]¶
Bases:
dictSession store for storing session data.
Initialization
Initializes the session store.
- __slots__¶
None
- static check_session_storage_connector(method)[source]¶
Decorator to ensure a valid session storage connector is present.
Validates: - Attribute exists - Attribute is not None - Attribute is correct type
- delete(session_key: Optional[str] = None)[source]¶
Deletes and clears the session from session storage.
- Parameters:
session_key – The session key or None if you want to use the current session key.
- exists(session_key: Optional[str] = None) bool[source]¶
Checks if a session with the specified key exists.
- Parameters:
session_key – The session key or None if you want to use the current session key.
- property loaded: bool¶
Returns the state whether the session has been loaded.
- property modified: bool¶
Returns the state whether the session has been modified after load or creation.
- needs_update() bool[source]¶
Returns whether the session data is worthy to be saved, this is the lazy behavior of Duck.
- session_expired() bool[source]¶
Returns boolean on whether if the session has expired depending on expiry set on session.
- property session_key¶
- set_expiry(expiry: Optional[Union[int, float, datetime.datetime, datetime.timedelta]] = None)[source]¶
Sets the session expiry.
- Parameters:
Optional[Union[int (expiry) – Float or int represents the seconds to expire from now and None represents the now plus the default session max_age.
float – Float or int represents the seconds to expire from now and None represents the now plus the default session max_age.
datetime.datetime – Float or int represents the seconds to expire from now and None represents the now plus the default session max_age.
datetime.timedelta]] – Float or int represents the seconds to expire from now and None represents the now plus the default session max_age.
- duck.http.session.engine.session_connector_mod¶
‘import_module_once(…)’