[Grok-dev] trails vs routes

Wichert Akkerman wichert at wiggy.net
Sat May 3 09:51:49 EDT 2008


I'm looking at megrok.trails and comparing it with routes to see what
their differences are. I'm interested in trying to use routes itself in
zope, if needed with some grok sauce. Routes is used by several popular
python web frameworks and I think it can be useful to have a consistent
approach across frameworks.

megrok.trails is much simpler than routes. It does not support things
like named routes, wildcards, groupings, defaults, requirements,
conditions, filters, etc. Since most of those are only rarely used that
is not a problem.

There are some conceptual differences: Routes is heavily based around
the concept of ``controllers`` classes which have ``action`` methods.
Matched routes end up instantiating a controller and calling an action
method on it. This method returns the response and ends the publication
process.

In the zope world things work differently so this model does not quite
fit. The megrok.trails approach is to use routes (which it calls trails)
to find a class to use and instantiates that, optionally with a list of
named parameters determined by the traversed URL. In grok terms that
means it returns a model, where routes would return a (rendered) view.

To me returning a view instead of a model makes more sense. I'ld like to
hear some opinions from others.

Wichert.


-- 
Wichert Akkerman <wichert at wiggy.net>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.


More information about the Grok-dev mailing list