Package cherrypy :: Module _cptools :: Class HandlerWrapperTool
[hide private]
[frames] | no frames]

Class HandlerWrapperTool

source code

object --+    
         |    
      Tool --+
             |
            HandlerWrapperTool

Tool which wraps request.handler in a provided wrapper function.

The 'newhandler' arg must be a handler wrapper function that takes a
'next_handler' argument, plus *args and **kwargs. Like all page handler
functions, it must return an iterable for use as cherrypy.response.body.

For example, to allow your 'inner' page handlers to return dicts
which then get interpolated into a template:

    def interpolator(next_handler, *args, **kwargs):
        filename = cherrypy.request.config.get('template')
        cherrypy.response.template = env.get_template(filename)
        response_dict = next_handler(*args, **kwargs)
        return cherrypy.response.template.render(**response_dict)
    cherrypy.tools.jinja = HandlerWrapperTool(interpolator)

Instance Methods [hide private]
 
__init__(self, newhandler, point='before_handler', name=None, priority=50)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
callable(self) source code

Inherited from Tool: __call__

Inherited from Tool (private): _merged_args, _setargs, _setup

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from Tool: namespace

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, newhandler, point='before_handler', name=None, priority=50)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)