diff options
| author | Michael Merickel <michael@merickel.org> | 2018-05-15 23:48:25 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-15 23:48:25 -0500 |
| commit | 7267a4491d0009517fdac2bfd0af78f19934efba (patch) | |
| tree | d786162d971e2290a6fac5a2ce5c5b0c993ef038 /docs | |
| parent | 07378673d8eb974069cbae2cd111eb03a9853910 (diff) | |
| parent | f6aee3428aa70bc8d09ccee46076d0f415c3965d (diff) | |
| download | pyramid-7267a4491d0009517fdac2bfd0af78f19934efba.tar.gz pyramid-7267a4491d0009517fdac2bfd0af78f19934efba.tar.bz2 pyramid-7267a4491d0009517fdac2bfd0af78f19934efba.zip | |
Merge pull request #3279 from huntcsg/master
Add Configurator context manager 'route_prefix_context' to allow for …
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/narr/urldispatch.rst | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst index 9ac01e24a..00c7bd3bf 100644 --- a/docs/narr/urldispatch.rst +++ b/docs/narr/urldispatch.rst @@ -1045,6 +1045,24 @@ may be added in the future. For example: config = Configurator() config.include(users_include, route_prefix='/users') +A convenience context manager exists to set the route prefix for any +:meth:`pyramid.config.Configurator.add_route` or +:meth:`pyramid.config.Configurator.include` calls within the context. + +.. code-block:: python + :linenos: + + from pyramid.config import Configurator + + def timing_include(config): + config.add_route('timing.show_times', '/times') + + def main(global_config, **settings) + config = Configurator() + with config.route_prefix_context('/timing'): + config.include(timing_include) + config.add_route('timing.average', '/average') + .. index:: single: route predicates (custom) |
