OpenQuizz
Une application de gestion des contenus pédagogiques
RequestContext Class Reference
Inheritance diagram for RequestContext:
Collaboration diagram for RequestContext:

Public Member Functions

def __init__ (self, app, environ, request=None, session=None)
 
def g (self)
 
def g (self, value)
 
def copy (self)
 
def match_request (self)
 
def push (self)
 
def pop (self, exc=_sentinel)
 
def auto_pop (self, exc)
 
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_value, tb)
 
def __repr__ (self)
 

Data Fields

 app
 
 request
 
 url_adapter
 
 flashes
 
 session
 
 preserved
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  app,
  environ,
  request = None,
  session = None 
)

Member Function Documentation

◆ __enter__()

def __enter__ (   self)

◆ __exit__()

def __exit__ (   self,
  exc_type,
  exc_value,
  tb 
)

◆ __repr__()

def __repr__ (   self)

◆ auto_pop()

def auto_pop (   self,
  exc 
)

◆ copy()

def copy (   self)
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.

◆ g() [1/2]

def g (   self)

◆ g() [2/2]

def g (   self,
  value 
)

◆ match_request()

def match_request (   self)
Can be overridden by a subclass to hook into the matching
of the request.

◆ pop()

def pop (   self,
  exc = _sentinel 
)
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.

◆ push()

def push (   self)
Binds the request context to the current context.

Field Documentation

◆ app

app

◆ flashes

flashes

◆ preserved

preserved

◆ request

request

◆ session

session

◆ url_adapter

url_adapter

The documentation for this class was generated from the following file: