summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2018-11-11 22:39:52 -0600
committerMichael Merickel <michael@merickel.org>2018-11-11 23:45:24 -0600
commitdff0798e352d0afeeec2058200ac983692b606c2 (patch)
tree9e6c4da2d683db86808437e0af1aad1231cdc846 /docs
parentebb56ebe4dd0cbecd6d19b5741ddf52c96a0176d (diff)
downloadpyramid-dff0798e352d0afeeec2058200ac983692b606c2.tar.gz
pyramid-dff0798e352d0afeeec2058200ac983692b606c2.tar.bz2
pyramid-dff0798e352d0afeeec2058200ac983692b606c2.zip
use inherit_slash=True on add_route to opt-in to no trailing slash
Diffstat (limited to 'docs')
-rw-r--r--docs/glossary.rst4
-rw-r--r--docs/narr/urldispatch.rst10
2 files changed, 8 insertions, 6 deletions
diff --git a/docs/glossary.rst b/docs/glossary.rst
index 4668efe6d..f42b298df 100644
--- a/docs/glossary.rst
+++ b/docs/glossary.rst
@@ -1203,3 +1203,7 @@ Glossary
A media type is a nested structure containing a top-level type and a subtype.
Optionally, a media type can also contain parameters specific to the type.
See :rfc:`6838` for more information about media types.
+
+ route prefix
+ A route prefix is a path prefix that is prepended to any routes that are configured while it is active.
+ A route prefix can be set via :meth:`pyramid.config.Configurator.include` or :meth:`pyramid.config.Configurator.route_prefix_context`.
diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst
index 701326fab..3b737b46d 100644
--- a/docs/narr/urldispatch.rst
+++ b/docs/narr/urldispatch.rst
@@ -971,7 +971,7 @@ application from small and potentially reusable components.
The :meth:`pyramid.config.Configurator.include` method accepts an argument
named ``route_prefix`` which can be useful to authors of URL-dispatch-based
applications. If ``route_prefix`` is supplied to the include method, it must
-be a string. This string represents a route prefix that will be prepended to
+be a string. This string represents a :term:`route prefix` that will be prepended to
all route patterns added by the *included* configuration. Any calls to
:meth:`pyramid.config.Configurator.add_route` within the included callable will
have their pattern prefixed with the value of ``route_prefix``. This can be
@@ -998,8 +998,7 @@ then only match if the URL path is ``/users/show``, and when the
:meth:`pyramid.request.Request.route_url` function is called with the route
name ``show_users``, it will generate a URL with that same path.
-To create a prefixed route that matches requests to the ``route_prefix``
-without a trailing slash set the route ``pattern`` to an empty string.
+To create a route that matches requests to the ``route_prefix`` without a trailing slash, pass ``inherit_slash=True`` to the call to ``add_route``.
.. code-block:: python
:linenos:
@@ -1007,14 +1006,13 @@ without a trailing slash set the route ``pattern`` to an empty string.
from pyramid.config import Configurator
def users_include(config):
- config.add_route('show_users', '')
+ config.add_route('show_users', '', inherit_slash=True)
def main(global_config, **settings):
config = Configurator()
config.include(users_include, route_prefix='/users')
-The above configuration will match ``/users`` instead of ``/users/`` if a slash
-had been supplied to the :meth:`pyramid.config.Configurator.add_route` function.
+The above configuration will match ``/users`` instead of ``/users/``.
Route prefixes are recursive, so if a callable executed via an include itself
turns around and includes another callable, the second-level route prefix will