Skip to main content

URL routing made right

Project description

Just a small example:

from routr import route, GET, POST
from routr.schema import form, String

def create_user(username=None):

def get_user(id):

routes = route("/users",
  route(POST, "/",          form(username=String), create_user),
  route(GET,  "/{id:int}",  get_user)

Docs are hosted at excellent readthedocs project.


  • Fix Python 3 support for routr.utils.import_string shared function.


  • Initial Python 3.2 and 3.3 support. Also backport to Python 2.6.


  • Trace.annotation(name, default=None) method to retrieve annotation from routes.


  • routr.static.static accepts annotations

  • routr.static.static returns Response subclass’ object


  • schema validation and doc generation moved to separate packages


  • fix bug with trace.args/kwargs updates


  • use schemify for schema validation

  • remove routr.schema completely

  • remove routr.schema2qs and form guards are now can be imported directly from routr module


  • routr.schema2: opt now can provide default value

  • routr.schema2: allow namedtuple-based schemas


  • HTTP methods constants now can be used to define routes


  • allow setting custom class for URL matching – use url_pattern_cls keyword argument for route directive

  • lightweight schema validation package routr.schema2


  • URL pattern type str now has re arg – allows to validate string via regexp


  • fix url pattern matching for labels with numbers, like /{id1}


  • routr.static.static routes now can be distinguished via static_view annotation instead of view attribute (still here for backward compatibility)


  • fix routr.static behaviour


  • get rid of Configuration, now route is just a plain function – this allows better composability w/o requirement to share configuration object between different parts of the app

  • add routr.static for serving static files

  • add routr.utils.positional_args for introspection of positional arguments of different types of objects and routr.utils.inject_args for injecting positional arguments based on introspection


  • bugfixes to DSL


  • [not backward compatible] new DSL – got rid of guards keyword argument which is too noisy


  • [bugfix] incorrect reversal of urls with more than one param


  • [bugfix] fix bug with RouteGuarded poped up in RouteGroup match

  • add ‘_’ to allowed args in URLPattern


  • introduced RequestParams.exception_factory which abstracts away HTTPBadRequest raise in case of invalid data being supplied

  • [bugfix] RouteGuarded.response now installed correctly, previously it sometimes contained NoUrlMatched objects which are not responses


  • RequestParams.post_processor now also can be accumulated via addition

  • fix bug in RequestParams which prevented Option wrap SchemaNode objects directly


  • fix broken 0.1.2 release by including CHANGES file in dist


  • trace factory made configurable via Configuration.trace attribute

  • method and PATH_INFO extraction delegated to configuration, allows implementing routing for other request wrapper (werkzeug or django’s request for example)

  • routes now have access to configuration object via cfg attribute


  • allow guards return None (routing doesn’t break on this and proceed with old trace)

  • RequestParams now can accept colander.SchemaNode directly (allows to supply validators)


  • initial release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

routr-0.7.2.tar.gz (14.9 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page