diff options
| author | Chris McDonough <chrism@agendaless.com> | 2008-07-22 11:12:12 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2008-07-22 11:12:12 +0000 |
| commit | c1a6ef6f751a16b7a352bc3fdad13d4b5b73f212 (patch) | |
| tree | 7ab06ad1d271eac67593d9e8403b8a5fa1c2f408 /docs/api | |
| parent | 8392d7094c96f777f6d1d5f0c62051702191d106 (diff) | |
| download | pyramid-c1a6ef6f751a16b7a352bc3fdad13d4b5b73f212.tar.gz pyramid-c1a6ef6f751a16b7a352bc3fdad13d4b5b73f212.tar.bz2 pyramid-c1a6ef6f751a16b7a352bc3fdad13d4b5b73f212.zip | |
Diffstat (limited to 'docs/api')
| -rw-r--r-- | docs/api/urldispatch.rst | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/docs/api/urldispatch.rst b/docs/api/urldispatch.rst index 81b28cebb..18edddc8a 100644 --- a/docs/api/urldispatch.rst +++ b/docs/api/urldispatch.rst @@ -22,9 +22,26 @@ of dispatch:: <bfg:view for="repoze.bfg.interfaces.IURLDispatchModel" - view=".views.url_dispatch_view" - name="url_dispatch_controller" + view=".views.articles_view" + name="articles" /> -This view will be called with its context as a model with attributes -matching the Routes routing dictionary associated with the request. +You might then configure the ``RoutesMapper`` like so:: + + def fallback_get_root(environ): + return {} # the graph traversal root is empty in this example + + get_root = RoutesMapper(fallback_get_root) + get_root.connect('archives/:article', controller='articles') + + import myapp + from repoze.bfg.router import make_app + + app = make_app(get_root, myapp) + +At this point, if any URL matches the pattern ``archives/:article``, +the ``.views.articles_view`` view will be called with its context as a +only-the-fly-generated-model with attributes matching the Routes +routing dictionary associated with the request. In particular, in +this case the model will have an ``article`` attribute matching the +article picked off the URL by Routes. |
