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 :

Module « flask.ctx »

Classe « RequestContext »

Informations générales

Héritage

builtins.object
    RequestContext

Définition

class RequestContext(builtins.object):

Description [extrait de RequestContext.__doc__]

The request context contains all request relevant information.  It is
    created at the beginning of the request and pushed to the
    `_request_ctx_stack` and removed at the end of it.  It will create the
    URL adapter and request object for the WSGI environment provided.

    Do not attempt to use this class directly, instead use
    :meth:`~flask.Flask.test_request_context` and
    :meth:`~flask.Flask.request_context` to create this object.

    When the request context is popped, it will evaluate all the
    functions registered on the application for teardown execution
    (:meth:`~flask.Flask.teardown_request`).

    The request context is automatically popped at the end of the request
    for you.  In debug mode the request context is kept around if
    exceptions happen so that interactive debuggers have a chance to
    introspect the data.  With 0.4 this can also be forced for requests
    that did not fail and outside of ``DEBUG`` mode.  By setting
    ``'flask._preserve_context'`` to ``True`` on the WSGI environment the
    context will not pop itself at the end of the request.  This is used by
    the :meth:`~flask.Flask.test_client` for example to implement the
    deferred cleanup functionality.

    You might find this helpful for unittests where you need the
    information from the context local around for a little longer.  Make
    sure to properly :meth:`~werkzeug.LocalStack.pop` the stack yourself in
    that situation, otherwise your unittests will leak memory.
    

Constructeur(s)

Signature du constructeur Description
__init__(self, app: 'Flask', environ: dict, request: Optional[ForwardRef('Request')] = None, session: Optional[ForwardRef('SessionMixin')] = None) -> None

Liste des propriétés

Nom de la propriétéDescription
g

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
__enter__(self) -> 'RequestContext'
__exit__(self, exc_type: type, exc_value: BaseException, tb: traceback) -> None
__repr__(self) -> str
auto_pop(self, exc: Optional[BaseException]) -> None
copy(self) -> 'RequestContext' Creates a copy of this request context with the same request object. [extrait de copy.__doc__]
match_request(self) -> None Can be overridden by a subclass to hook into the matching [extrait de match_request.__doc__]
pop(self, exc: Optional[BaseException] = <object object at 0x7f40e98e2d00>) -> None Pops the request context and unbinds it by doing that. This will [extrait de pop.__doc__]
push(self) -> None Binds the request context to the current context. [extrait de push.__doc__]

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

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