megrok.traject
megrok.traject is a library that integrates the traject routing framework with the Grok web framework.
Include megrok.traject by adding it in your Grok project’s setup.py (in install_requires) and re-running buildout.
With megrok.traject you can declare trajects in Grok like this:
from megrok import traject
class SomeTraject(traject.Traject):
grok.context(App)
pattern = 'departments/:department_id'
model = Department
def factory(department_id):
return get_department(department_id)
def arguments(department):
return dict(department_id=department.id)
This registers factory and the inverse arguments functions for the pattern departments/:department_id, the root App and the class Department. This replaces the register* functions in traject itself.
App is any grok model. This model now automatically allows traversal into the associated patterns; the system registers a custom traverser to do this.
You can register grok views for Department as usual.
Tips:
return None in factory if the model cannot be found. The system then falls back to normal traversal to look up the view. Being too aggressive in consuming any arguments will break view traversal.
Use megrok.traject.locate to locate an object before asking for its URL or doing checkPermission on it. If the object was routed to using megrok.traject already this isn’t necessary. This is a simple import alias for traject.locate.
For more information see the traject documentation.
CHANGES.txt
0.9 (2009-11-16)
Initial public release.
Download
Metadata
Release files for megrok.traject 0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| megrok.traject-0.9.tar.gz | 7.6 kB | Details |
Release files / megrok.traject-0.9.tar.gz
| Download URL | megrok.traject-0.9.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
762c3ca1bdbab04915c9647fb3bfba20cf4e08e97d3b18a5cbf57252a36a8acb
|
|
BLAKE2b-256 checksum How to use checksums |
a39bf472f2ee85250a72affbd98fb1527a3d3e02a80fda0aa648e2d889538cec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |