class RequestContext: (source)
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 |
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 |
Undocumented |
Instance Variable | _after |
Undocumented |
Instance Variable | _cv |
Undocumented |
t.Optional[ type]
, exc_value: t.Optional[ BaseException]
, tb: t.Optional[ TracebackType]
):
(source)
¶
Undocumented
Flask
, environ: dict
, request: t.Optional[ Request]
= None, session: t.Optional[ SessionMixin]
= None):
(source)
¶
Undocumented
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.