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

Public Member Functions

def __init__ (self, locals=None, ident_func=None)
 
def get_ident (self)
 
def cleanup (self)
 
def make_middleware (self, app)
 
def middleware (self, func)
 
def __repr__ (self)
 

Data Fields

 locals
 
 ident_func
 

Detailed Description

Local objects cannot manage themselves. For that you need a local
manager.  You can pass a local manager multiple locals or add them later
by appending them to `manager.locals`.  Every time the manager cleans up,
it will clean up all the data left in the locals for this context.

The `ident_func` parameter can be added to override the default ident
function for the wrapped locals.

.. versionchanged:: 0.6.1
   Instead of a manager the :func:`release_local` function can be used
   as well.

.. versionchanged:: 0.7
   `ident_func` was added.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  locals = None,
  ident_func = None 
)

Member Function Documentation

◆ __repr__()

def __repr__ (   self)

◆ cleanup()

def cleanup (   self)
Manually clean up the data in the locals for this context.  Call
this at the end of the request or use `make_middleware()`.

◆ get_ident()

def get_ident (   self)
Return the context identifier the local objects use internally for
this context.  You cannot override this method to change the behavior
but use it to link other context local objects (such as SQLAlchemy's
scoped sessions) to the Werkzeug locals.

.. versionchanged:: 0.7
   You can pass a different ident function to the local manager that
   will then be propagated to all the locals passed to the
   constructor.

◆ make_middleware()

def make_middleware (   self,
  app 
)
Wrap a WSGI application so that cleaning up happens after
request end.

◆ middleware()

def middleware (   self,
  func 
)
Like `make_middleware` but for decorating functions.

Example usage::

    @manager.middleware
    def application(environ, start_response):
...

The difference to `make_middleware` is that the function passed
will have all the arguments copied from the inner application
(name, docstring, module).

Field Documentation

◆ ident_func

ident_func

◆ locals

locals

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