This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Warouter is a simple routing wrapper around webapp2.

Project Description

Warouter is a simple routing wrapper around webapp2.

Installing

$ pip install warouter

Usage

Warouter provides url inheritance for handlers and a convenient uri_for function which can be called with a handler, instead of a string name.

A WSGIApplication mixin is provided which can handle a list of url decorator handlers.

Example:

>>> import warouter
>>> import webapp2
>>>
>>> @warouter.url('/')
... class RootHandler(webapp2.RequestHandler):
...     def get(self):
...         self.response.write('root')
...
>>> @warouter.url('/child/<child_param:([a-z]+)>')
... class ChildHandler(RootHandler):
...     def get(self, child_param):
...         self.response.write(child_param)
...     def put(self, child_param):
...         pass
...
>>> @warouter.url('/grandchild/<grandchild_param:([a-z]+)>')
... class GrandChildHandler(ChildHandler):
...     def get(self, child_param, grandchild_param):
...         self.response.write('\n'.join([child_param, grandchild_param]))
...     def post(self, child_param, grandchild_param):
...         self.response.write(warouter.uri_for(ChildHandler,
...                                              child_param=child_param))
...
>>> assert RootHandler.url == '/'
>>> assert ChildHandler.url == '/child/<child_param:([a-z]+)>'
>>> assert GrandChildHandler.url == (
...     '/child/<child_param:([a-z]+)>/grandchild/<grandchild_param:([a-z]+)>')
>>> assert GrandChildHandler.put is None
>>>
>>> app = warouter.WSGIApplication([
...     RootHandler,
...     ChildHandler,
...     GrandChildHandler
... ])
>>>
>>> if __name__ == '__main__':
...     from paste import httpserver
...     httpserver.serve(app, port='8080')
...
>>>

The above example requires Paste, which can be installed using:

$ pip install paste

License

MIT

Release History

Release History

This version
History Node

0.1.1

History Node

0.1.0

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
warouter-0.1.1-py27-none-any.whl (5.6 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Feb 24, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting