Johan Hartzenberg <
jo...@webmaster.co.za> writes:
> I've just noticed the RoutesDispatcher and it's mapper function appears
> very similar to what is described in the Routes documentation. Complete
> with lacking explanation of how the map decides which of the app's Class
> method's will be used for any matched route. I'm tempted to assume that
> the "action" attribute will look for a class method with the same name?
Yes, though that's really a Routes question than a CherryPy question.
The RoutesDispatcher is a very thin layer on top of Routes.Mapper plus
support for the CherryPy configuration stuff - for the actual mapping,
connect() is just Routes.Mapper.connect, and URL lookup uses
Routes.Mapper.match().
Routes associates the URL lookup with a controller (the object) and an
action (the method) and any other arguments that method needs. Not
all of those elements need to be in the URL itself, as you can assign
explicit values if needed. (For example, see the example on line 4 of
"Setting up Routes" in the Routes documentation - the "/" URL has
static controller and action values)
RoutesDispatcher itself (in _cpdispatch.py) is only about 100 lines so
very easy to review if you have any questions as to how it interfaces
with Routes.
-- David