Package cherrypy :: Module _cpdispatch :: Class Dispatcher
[hide private]
[frames] | no frames]

Class Dispatcher

source code

object --+
         |
        Dispatcher
Known Subclasses:

CherryPy Dispatcher which walks a tree of objects to find a handler.

The tree is rooted at cherrypy.request.app.root, and each hierarchical component in the path_info argument is matched to a corresponding nested attribute of the root object. Matching handlers must have an 'exposed' attribute which evaluates to True. The special method name "index" matches a URI which ends in a slash ("/"). The special method name "default" may match a portion of the path_info (but only when no longer substring of the path_info matches some other object).

This is the default, built-in dispatcher for CherryPy.

Instance Methods [hide private]
 
__call__(self, path_info)
Set handler and config for the current request.
source code
 
find_handler(self, path)
Return the appropriate page handler, plus any virtual path.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

find_handler(self, path)

source code 

Return the appropriate page handler, plus any virtual path.

This will return two objects. The first will be a callable, which can be used to generate page output. Any parameters from the query string or request body will be sent to that callable as keyword arguments.

The callable is found by traversing the application's tree, starting from cherrypy.request.app.root, and matching path components to successive objects in the tree. For example, the URL "/path/to/handler" might return root.path.to.handler.

The second object returned will be a list of names which are 'virtual path' components: parts of the URL which are dynamic, and were not used when looking up the handler. These virtual path components are passed to the handler as positional arguments.