def _extends_preproc(prefunc):
<EOL>functions = dict(preproc=prefunc)<EOL>@functools.wraps(prefunc)<EOL>def wrapper(self, req, **params):<EOL><INDENT>resp = yield functions['<STR_LIT>'](self, req, **params)<EOL>if '<STR_LIT>' in functions:<EOL><INDENT>yield functions['<STR_LIT>'](self, req, resp, **params)<EOL><DEDENT><DEDENT>def postproc(postfunc):<EOL><INDENT>"""<STR_LIT>"""<EOL>if prefunc.__name__ != postfunc.__name__:<EOL><INDENT>raise TypeError("<STR_LIT>" %<EOL>prefunc.__name__)<EOL><DEDENT>functions['<STR_LIT>'] = postfunc<EOL>return wrapper<EOL><DEDENT>wrapper._wsgi_extension = True  <EOL>wrapper._wsgi_extension_functions = functions<EOL>wrapper.postproc = postproc<EOL>return wrapper<EOL>
Decorator which marks a method as a preprocessing extension.  The
method must have the same name as the method it is extending.
Extension methods marked with this decorator are called before
calling the action method.  They may perform any desired
preprocessing of the request.  Note that if an actual value is
returned to the caller, the normal request processing is aborted.
Also note that the postprocessing portions of all prior extensions
*will* be called on the returned response.

This decorator works by converting the decorated method into a
generator, which is called as described in the documentation for
``@extends``.  (It is not necessary to additionally use the
``@extends`` decorator on the method.)

To additionally add a post-processing phase, decorate the
post-processing method (which must have the same name as the
original method) with the ``@postproc`` decorator, i.e.:

    class Controller(appathy.Controller):
        @extends.preproc
        def show(self, req, id):
            pass

        @show.postproc
        def show(self, req, resp, id):
            pass

If you don't need preprocessing, use the ``@extends`` decorator
instead.