Back to index

moin  1.9.0~rc2
Public Member Functions | Private Attributes Class Reference

List of all members.

Public Member Functions

def __init__
def __iter__
def next
def close

Private Attributes


Detailed Description

The WSGI specification requires that all middlewares and gateways
respect the `close` callback of an iterator.  Because it is useful to add
another close action to a returned iterator and adding a custom iterator
is a boring task this class can be used for that::

    return ClosingIterator(app(environ, start_response), [cleanup_session,

If there is just one close function it can be passed instead of the list.

A closing iterator is not needed if the application uses response objects
and finishes the processing if the response is started::

        return response(environ, start_response)

Definition at line 311 of file

Constructor & Destructor Documentation

def (   self,
  callbacks = None 

Definition at line 332 of file

00333     def __init__(self, iterable, callbacks=None):
00334         iterator = iter(iterable)
00335         self._next =
00336         if callbacks is None:
00337             callbacks = []
00338         elif callable(callbacks):
00339             callbacks = [callbacks]
00340         else:
00341             callbacks = list(callbacks)
00342         iterable_close = getattr(iterator, 'close', None)
00343         if iterable_close:
00344             callbacks.insert(0, iterable_close)
00345         self._callbacks = callbacks

Member Function Documentation

Definition at line 346 of file

00347     def __iter__(self):
00348         return self

Definition at line 352 of file

00353     def close(self):
00354         for callback in self._callbacks:
00355             callback()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 349 of file

00350     def next(self):
00351         return self._next()

Here is the caller graph for this function:

Member Data Documentation

Definition at line 344 of file

Definition at line 334 of file

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