Session¶
Initialize session interface and default config variables.
-
invenio_ext.session.
setup_app
(app)¶ Create custom session interface.
Backends¶
Implementation of several session backends.
Cache¶
Flask-Cache backend for session.
Configuration variables for Flask-Cache backend.
SESSION_BACKEND_CACHE | Configured Flask-Cache object.
Default: invenio_ext.cache:cache |
SESSION_BACKEND_CACHE_PREFIX | Prefix for keys stored in cache.
Default: session:: |
SESSION_BACKEND_CACHE_TIMEOUT | Default cache timeout. Default: 3600 |
-
class
invenio_ext.session.backends.cache.
Storage
¶ Bases:
invenio_ext.session.storage.SessionStorage
Implement session cache storage.
-
cache
¶ Return cache storage.
-
delete
(name)¶ Delete key from cache.
-
get
(name)¶ Return value from cache.
-
key
¶ Return cache key prefix.
-
set
(name, value, timeout=None)¶ Store value in cache.
-
timeout
¶ Return cache engine timeout.
-
SQLAlchemy¶
SQLAlchemy backend for session.
Configuration variables for SQLAlchemy backend.
SESSION_BACKEND_SQLALCHEMY | Configured Flask-SQLAlchemy object.
Default: invenio_ext.sqlalchemy:db |
SESSION_BACKEND_SQLALCHEMY_MODEL | SQLAlchemy ORM model. Default:
invenio_ext.session.model:Session' |
SESSION_BACKEND_SQLALCHEMY_GETTER | Name of method on model to retrieve session
data. Default: get_session |
SESSION_BACKEND_SQLALCHEMY_SETTER | Name of method on medel to set session
data. Default: set_session |
SESSION_BACKEND_SQLALCHEMY_VALUE | Name of model attribute where to store
session data. Default:
session_object |
-
class
invenio_ext.session.backends.sqlalchemy.
Storage
(*args, **kwargs)¶ Bases:
invenio_ext.session.storage.SessionStorage
Implement database backend for SQLAlchemy model storage.
-
db
¶ Return SQLAlchemy database object.
-
delete
(name)¶ Delete key from database table.
-
get
(name)¶ Return value from database table.
-
getter
¶ Return method to get session value.
-
model
¶ Return SQLAlchemy model.
-
set
(name, value, timeout=None)¶ Store value in database table.
-
setter
¶ Return method to set session value.
-
value
¶ Return model property for storing session value.
-
Model¶
Wrappers¶
Flask SessionInterface
implementation.
-
class
invenio_ext.session.interface.
SessionInterface
¶ Bases:
flask.sessions.SessionInterface
Extend
SessionInterface
class.-
backend
¶ Return session backend.
-
generate_sid
()¶ Generate unique session identifier.
-
get_session_expiration_time
(app, session)¶ Return session expiration time.
-
get_signer
()¶ Return signer for cookie content signing.
-
has_secure_url
¶ Return
True
if secure url is configured.
-
open_session
(app, request)¶ Return session instance.
-
save_session
(app, session, response)¶ Save current session.
-
serializer
¶ Return serializer class.
-
session_class
¶ Return session class.
-
sign_salt
¶ Return salt for session id signing.
-
sign_sid
¶ Return
True
if cookie session id is signed.
-
Session storage interface.