summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorCharlie Choiniere <nek4life@gmail.com>2015-04-17 07:12:11 -0400
committerCharlie Choiniere <nek4life@gmail.com>2015-04-17 07:12:11 -0400
commit855fe374108779e82530da74f1c0fd21ab9033b3 (patch)
tree99147d5a46720d5747bcc2fc1758a3ceb96c2835 /docs
parent2f66ff514717b29bf1cd5fea668164ac67d70cea (diff)
downloadpyramid-855fe374108779e82530da74f1c0fd21ab9033b3.tar.gz
pyramid-855fe374108779e82530da74f1c0fd21ab9033b3.tar.bz2
pyramid-855fe374108779e82530da74f1c0fd21ab9033b3.zip
Added support for a prefixed base url to not contain a trailing slash
Diffstat (limited to 'docs')
-rw-r--r--docs/narr/urldispatch.rst18
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst
index 87a962a9a..f2a94341d 100644
--- a/docs/narr/urldispatch.rst
+++ b/docs/narr/urldispatch.rst
@@ -964,6 +964,24 @@ 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.
+
+.. code-block:: python
+ :linenos:
+
+ from pyramid.config import Configurator
+
+ def users_include(config):
+ config.add_route('show_users', '')
+
+ 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.
+
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 be prepended with the first: