Issue #687 new

Dispatcher nesting should be unfolded

Robert Brewer
created an issue

The ability to nest multiple dispatchers (i.e. have one dispatcher call another) is powerful and necessary; however, the current implementation suffers in that Python code cannot inspect the chain of dispatchers. For example:



from cherrypy.dispatch import *

hostmap = {'': '/mydom2', '': '/mydom3', '': '/dom4', } vh = VirtualHost(next_dispatcher=XMLRPCDispatcher(), **hostmap) cherrypy.tree.mount(root, config={'/': {'request.dispatch': vh}}) }}}

Although the !VirtualHost dispatcher wraps another dispatcher (and in this case, the XMLRPC dispatcher also wraps the default builtin CherryPy dispatcher), there is no interface exposed to Python code to inspect any dispatcher beyond the outermost one. Having just a simple means to iterate over the dispatchers involved in a chain would be a huge improvement.

Comments (5)

  1. Anonymous

    Could you show me a use case?

    I understand that from a purity perspective it would be nice but I don't quite see how this would add any value currently. Do you want CherryPy to make different decision based on the next dispatcher?

    I would not call that a defect either since it's not a bug per se AFAIK.

  2. Anonymous

    Robert, would you think having a DispatcherManager or some sort of higher level class that "knows" what there is to know about each dispatcher, be better? It feels "java-ish" but might solve your concern. I'm not exactly sure what information you really want to retrieve nor for what purpose.

  3. Robert Brewer reporter

    Instead of a manager I'd prefer a set of interface constraints. One thing I'd like to retrieve would be the object trail, but it's more of a generic reaction against the "you can only traverse if you call" design. LateParamPageHandler has the same problem: it'd be nice if Tools could read/write the set of args that will be passed to the handler.

  4. Log in to comment