Routing (Werkzeug)¶
state: | stable |
---|---|
dependencies: | Werkzeug |
feature: | routing |
This extension implements routing via werkzeug.routing.
Configuration¶
The extension is configured with a simple dictionary where keys are paths to the modules that contain routing rules, and values define mounting points (prefixes) for the resulting URL maps. If the value is null, then it is assumed that the rules are mounted to the root.
Example (YAML):
tool.ext.werkzeug_routing.Routing:
foo.views: /foo/
bar.views: /
quux.views: null
In the above example the routing rules exported by both bar.Bar and quux.Quux are mounted to the root, while the rules provided by foo.Foo are submounted to /foo/.
API reference¶
- class tool.ext.werkzeug_routing.Routing(app, conf)¶
Werkzeug routing plugin for Tool.
- add_urls(rules, submount=None)¶
Parameters: - rules – list of rules or dotted path to module where the rules are exposed.
- submount – (string) prefix for the rules
- compile_rule(string, **kwargs)¶
Returns a list of werkzeug.routing.Rule objects based on given view’s attribute routing_rules as populated by the url() decorator.
Rules are not compiled there because at the moment when function is being decorated it is usually not yet known which routing library is going to be used.