class documentation

class RequestContext: (source)

View In Hierarchy

The request context contains per-request information. The Flask app creates and pushes it at the beginning of the request, then pops it at the end of the request. 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. When using the interactive debugger, the context will be restored so ``request`` is still accessible. Similarly, the test client can preserve the context after the request ends. However, teardown functions may already have closed some resources such as database connections.

Method __enter__ Undocumented
Method __exit__ Undocumented
Method __init__ Undocumented
Method __repr__ Undocumented
Method copy Creates a copy of this request context with the same request object. This can be used to move a request context to a different greenlet. Because the actual request object is the same this cannot be used to move a request context to a different thread unless access to the request object is locked.
Method match_request Can be overridden by a subclass to hook into the matching of the request.
Method pop Pops the request context and unbinds it by doing that. This will also trigger the execution of functions registered by the :meth:`~flask.Flask.teardown_request` decorator.
Method push Undocumented
Instance Variable app Undocumented
Instance Variable flashes Undocumented
Instance Variable request Undocumented
Instance Variable session Undocumented
Instance Variable url_adapter Undocumented
Instance Variable _after_request_functions Undocumented
Instance Variable _cv_tokens Undocumented
def __enter__(self) -> RequestContext: (source)

Undocumented

def __exit__(self, exc_type: t.Optional[type], exc_value: t.Optional[BaseException], tb: t.Optional[TracebackType]): (source)

Undocumented

def __init__(self, app: Flask, environ: dict, request: t.Optional[Request] = None, session: t.Optional[SessionMixin] = None): (source)

Undocumented

def __repr__(self) -> str: (source)

Undocumented

def copy(self) -> RequestContext: (source)

Creates a copy of this request context with the same request object. This can be used to move a request context to a different greenlet. Because the actual request object is the same this cannot be used to move a request context to a different thread unless access to the request object is locked. .. versionadded:: 0.10 .. versionchanged:: 1.1 The current session object is used instead of reloading the original data. This prevents `flask.session` pointing to an out-of-date object.

def match_request(self): (source)

Can be overridden by a subclass to hook into the matching of the request.

Pops the request context and unbinds it by doing that. This will also trigger the execution of functions registered by the :meth:`~flask.Flask.teardown_request` decorator. .. versionchanged:: 0.9 Added the `exc` argument.

def push(self): (source)

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

url_adapter = (source)

Undocumented

_after_request_functions: t.List[ft.AfterRequestCallable] = (source)

Undocumented