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¶
Bases:
ExceptionSession related errors.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- exception duck.http.session.engine.SessionExpired¶
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)¶
Bases:
dictSession store for storing session data.
Initialization
Initializes the session store.
- __delitem__(key)¶
- __getitem__(key)¶
- __repr__()¶
- __setitem__(key, value)¶
- __slots__¶
None
- static check_session_storage_connector(method)¶
Decorator to check if session storage is set and is correct.
- clear()¶
Clears all session data.
- create()¶
Creates a new session with a new session key.
- delete(session_key: Optional[str] = None)¶
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¶
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.
- static generate_session_id() str¶
Generates and returns a random session ID.
- get_expiry_age()¶
Returns the session max age from current settings.
- get_expiry_date()¶
Returns the datetime the session is going to expire.
- load() dict¶
Loads the session from storage.
- property modified: bool¶
Returns the state whether the session has been modified after load or creation.
- needs_update() bool¶
Returns whether the session data is worthy to be saved, this is the lazy behavior of Duck.
- pop(*args, **kwargs)¶
Pops some session data.
- popitem(*args, **kwargs)¶
Pops some session data.
- save(*_)¶
Saves the session to storage.
- property session_key¶
- set_expiry(expiry: Optional[Union[int, float, datetime.datetime, datetime.timedelta]] = None)¶
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.
- update(data: dict)¶
Overrides the update method to ensure items are tracked for modification.
- duck.http.session.engine.session_connector_mod¶
‘import_module_once(…)’