Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Calcul scientifique
avec Python
Voir le programme détaillé
Module « flask.sessions »

Classe « SessionInterface »

Informations générales

Héritage

builtins.object
    SessionInterface

Définition

class SessionInterface(builtins.object):

help(SessionInterface)

The basic interface you have to implement in order to replace the
default session interface which uses werkzeug's securecookie
implementation.  The only methods you have to implement are
:meth:`open_session` and :meth:`save_session`, the others have
useful defaults which you don't need to change.

The session object returned by the :meth:`open_session` method has to
provide a dictionary like interface plus the properties and methods
from the :class:`SessionMixin`.  We recommend just subclassing a dict
and adding that mixin::

    class Session(dict, SessionMixin):
        pass

If :meth:`open_session` returns ``None`` Flask will call into
:meth:`make_null_session` to create a session that acts as replacement
if the session support cannot work because some requirement is not
fulfilled.  The default :class:`NullSession` class that is created
will complain that the secret key was not set.

To replace the session interface on an application all you have to do
is to assign :attr:`flask.Flask.session_interface`::

    app = Flask(__name__)
    app.session_interface = MySessionInterface()

Multiple requests with the same session may be sent and handled
concurrently. When implementing a new session interface, consider
whether reads or writes to the backing store must be synchronized.
There is no guarantee on the order in which the session for each
request is opened or saved, it will occur in the order that requests
begin and end processing.

.. versionadded:: 0.8

Constructeur(s)

Signature du constructeur Description
__init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. [extrait de __init__.__doc__]

Liste des attributs statiques

Nom de l'attribut Valeur
pickle_basedFalse

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
get_cookie_domain(self, app: 'Flask') -> 'str | None' The value of the ``Domain`` parameter on the session cookie. If not set, [extrait de get_cookie_domain.__doc__]
get_cookie_httponly(self, app: 'Flask') -> 'bool' Returns True if the session cookie should be httponly. This [extrait de get_cookie_httponly.__doc__]
get_cookie_name(self, app: 'Flask') -> 'str' The name of the session cookie. Uses``app.config["SESSION_COOKIE_NAME"]``. [extrait de get_cookie_name.__doc__]
get_cookie_partitioned(self, app: 'Flask') -> 'bool' Returns True if the cookie should be partitioned. By default, uses [extrait de get_cookie_partitioned.__doc__]
get_cookie_path(self, app: 'Flask') -> 'str' Returns the path for which the cookie should be valid. The [extrait de get_cookie_path.__doc__]
get_cookie_samesite(self, app: 'Flask') -> 'str | None' Return ``'Strict'`` or ``'Lax'`` if the cookie should use the [extrait de get_cookie_samesite.__doc__]
get_cookie_secure(self, app: 'Flask') -> 'bool' Returns True if the cookie should be secure. This currently [extrait de get_cookie_secure.__doc__]
get_expiration_time(self, app: 'Flask', session: 'SessionMixin') -> 'datetime | None' A helper method that returns an expiration date for the session [extrait de get_expiration_time.__doc__]
is_null_session(self, obj: 'object') -> 'bool' Checks if a given object is a null session. Null sessions are [extrait de is_null_session.__doc__]
make_null_session(self, app: 'Flask') -> 'NullSession' Creates a null session which acts as a replacement object if the [extrait de make_null_session.__doc__]
open_session(self, app: 'Flask', request: 'Request') -> 'SessionMixin | None' This is called at the beginning of each request, after [extrait de open_session.__doc__]
save_session(self, app: 'Flask', session: 'SessionMixin', response: 'Response') -> 'None' This is called at the end of each request, after generating [extrait de save_session.__doc__]
should_set_cookie(self, app: 'Flask', session: 'SessionMixin') -> 'bool' Used by session backends to determine if a ``Set-Cookie`` header [extrait de should_set_cookie.__doc__]

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __getstate__, __hash__, __init_subclass__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Vous êtes un professionnel et vous avez besoin d'une formation ? Coder avec une
Intelligence Artificielle
Voir le programme détaillé