Routing Recognition and Generation Tools
Routes is a Python re-implementation of the Rails routes system for mapping URL's to Controllers/Actions and generating URL's. Routes makes it easy to create pretty and concise URL's that are RESTful with little effort.
Speedy and dynamic URL generation means you get a URL with minimal cruft (no big dangling query args). Shortcut features like Named Routes cut down on repetitive typing.
See the documentation for installation and usage of Routes <http://readthedocs.org/docs/routes/en/latest/>
_.
Routes Changelog %%%%%%%%%%%%%%%%
//
). PR #60. Patch by Sviatoslav Sydorenko.middleware
extra requirement, making possible to
depend on webob
optionally. PR #59. Patch by Sviatoslav Sydorenko.requirements
option when using
mapper.resource to create routes. PR #57. Patch by Sean Dague.WSGI.org Routing Vars Spec <http://wsgi.org/wsgi/Specifications/routing_args>
_.append_slash
. When set to True
, any URL's
generated will have a slash appended to the end.routes.init will now load the common symbols most people will want to actually use. Thus, you can either::
from routes import *
Or::
from routes import request_config, Mapper
The following names are available for importing from routes::
request_config, Mapper, url_for, redirect_to
Route Names - You can now name a route, which will save a copy of the defaults defined for later use by url_for or redirect_to. Thus, a route and url_for looking like this::
m.connect('home', controller='blog', action='splash')
url_for(controller='blog', action='splash') # => /home
Can now be used with a name::
m.connect('home_url','home', controller='blog', action='splash')
url_for('home_url') # => /home
Additional keywords can still be added to url_for and will override defaults in the named route.
Trailing / - Route recognition earlier failed on trailing slashes, not really a bug, not really a feature I guess. Anyways, trailing slashes are o.k. now as in the Rails version.
redirect_to now has two sets of tests to ensure it works properly