Ian Bicking: the old part of his blog

Re: Cherrypy and RhubarbTart

Is Routes name resolution high on the priority list? I'd be really interested in it. Ideally, I'd like to manage my URL's as a bunch of string/object mappings and totally bypass the normal cherrypy object hierarchy. I am particularly revolted by the object hierarchy because of the potential for name collisions. For example, I start with something like this:

class Root(object):
    def index(...):

    def otherstuff(...): # not exposed...yet

root = Root()

Later I decide to expose a URL "/otherstuff", which means I have to refactor my Root class. If I forget to do this and just tack it on like this:

root.otherstuff = OtherStuff()

which overwrites the original otherstuff attribute...HORRIBLE! Method names should be decoupled from URL mappings. This can mean a small bit of duplication, but it is usually all in one place (i.e. in the file that contains object/url mappings).

The other reason I want Routes is so I can map any URL to any function (even if the URL is not a valid Python identifier).

Comment on Cherrypy and RhubarbTart
by Daniel


Daniel, have you seen the custom cherrypy Request object for Routes I threw together? It allows you to totally bypass the CherryPy dispatch mechanism. http://www.aminus.org/blogs/index.php/fumanchu/2006/02/26/making_a_custom_cherrypy_request_class_f

# Robert Brewer