Routes based dispatching for TurboGears2
Project description
About tgext.routes
tgext.routes provides a simple way to integrate routes based dispatch into TurboGears2 applications through the @route decorator.
Installing
tgext.routes can be installed both from pypi or from bitbucket:
pip install tgext.routes
should just work for most of the users
Routing Actions
Routes matching is done through the @route decorator, each exposed method can be bound to one or multiple routes.
The only requirement is that you inherit from the RoutedController instance.
The following example registers the entry_by_date method for urls like /date/2012-01 and /date/2012-01-01:
from tgext.routes import RoutedController, route class DateController(RoutedController): @expose() @route('{year}-{month}', day=33) @route('{year}-{month}-{day}') def entry_by_date(self, year, month, day): return '%s ++ %s ++ %s' % (year, month, day) class RootController(BaseController): date = DateController() @expose() def index(self): return 'Hello!'
Keep in mind that tgext.routes doesn’t prevent the method to be accessed through ObjectDispatch routing, it just registers additional routes.
For more documentation about routes refer to Routes Documentation
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
File details
Details for the file tgext.routes-0.0.1.tar.gz
.
File metadata
- Download URL: tgext.routes-0.0.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca04c572fae130c1233cfdfc60d713b37c821225540018272003cf753dac05a6 |
|
MD5 | 434c7b4bb30f7d33d0d5e64427dc2778 |
|
BLAKE2b-256 | bd30aebaf9ff183eb4be265a87a9608b12b7fa2e824d4ef168486ef85cd90ff9 |