Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.support.werkzeug.local.LocalManager Class Reference

List of all members.

Public Member Functions

def __init__
def get_ident
def cleanup
def make_middleware
def middleware
def __repr__

Public Attributes

 locals

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`.  Everytime the manager cleans up
it, will clean up all the data left in the locals for this context.

Definition at line 141 of file local.py.


Constructor & Destructor Documentation

def MoinMoin.support.werkzeug.local.LocalManager.__init__ (   self,
  locals = None 
)

Definition at line 148 of file local.py.

00148 
00149     def __init__(self, locals=None):
00150         if locals is None:
00151             self.locals = []
00152         elif isinstance(locals, Local):
00153             self.locals = [locals]
00154         else:
00155             self.locals = list(locals)


Member Function Documentation

Definition at line 195 of file local.py.

00195 
00196     def __repr__(self):
00197         return '<%s storages: %d>' % (
00198             self.__class__.__name__,
00199             len(self.locals)
00200         )
00201 

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

Definition at line 164 of file local.py.

00164 
00165     def cleanup(self):
00166         """Manually clean up the data in the locals for this context.  Call
00167         this at the end of the request or use `make_middleware()`.
00168         """
00169         ident = self.get_ident()
00170         for local in self.locals:
00171             local.__storage__.pop(ident, None)

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Definition at line 156 of file local.py.

00156 
00157     def get_ident(self):
00158         """Return the context identifier the local objects use internally for
00159         this context.  You cannot override this method to change the behavior
00160         but use it to link other context local objects (such as SQLAlchemy's
00161         scoped sessions) to the Werkzeug locals.
00162         """
00163         return get_ident()

Here is the caller graph for this function:

Wrap a WSGI application so that cleaning up happens after
request end.

Definition at line 172 of file local.py.

00172 
00173     def make_middleware(self, app):
00174         """Wrap a WSGI application so that cleaning up happens after
00175         request end.
00176         """
00177         def application(environ, start_response):
00178             return ClosingIterator(app(environ, start_response), self.cleanup)
00179         return application

Here is the call graph for this function:

Here is the caller graph for this function:

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).

Definition at line 180 of file local.py.

00180 
00181     def middleware(self, func):
00182         """Like `make_middleware` but for decorating functions.
00183 
00184         Example usage::
00185 
00186             @manager.middleware
00187             def application(environ, start_response):
00188                 ...
00189 
00190         The difference to `make_middleware` is that the function passed
00191         will have all the arguments copied from the inner application
00192         (name, docstring, module).
00193         """
00194         return _patch_wrapper(func, self.make_middleware(func))

Here is the call graph for this function:


Member Data Documentation

Definition at line 150 of file local.py.


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