Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Minimally explain usage of custom regular expressions in URL dispatch

  replacement markers within URL Dispatch chapter.
  • Loading branch information...
commit 65f203e7290fdc9905896334ca87f5d34667d961 1 parent ff3ba5c
@mcdonc mcdonc authored
Showing with 15 additions and 6 deletions.
  1. +3 −0  CHANGES.txt
  2. +0 −6 TODO.txt
  3. +12 −0 docs/narr/urldispatch.rst
View
3  CHANGES.txt
@@ -53,6 +53,9 @@ Documentation
- Slightly improved interface docs for ``IAuthorizationPolicy``.
+- Minimally explain usage of custom regular expressions in URL dispatch
+ replacement markers within URL Dispatch chapter.
+
Deprecations
-------------
View
6 TODO.txt
@@ -1,12 +1,6 @@
Pyramid TODOs
=============
-Must-Have (before 1.0)
-----------------------
-
-- Explain ``{foo:<regex>}`` pattern formatting and purpose better in
- within URL dispatch chapter.
-
Should-Have
-----------
View
12 docs/narr/urldispatch.rst
@@ -252,6 +252,18 @@ the match result will be ``{'name': 'biz', 'ext': 'html'}``. This occurs
because there is a literal part of ``.`` (period) between the two replacement
markers ``{name}`` and ``{ext}``.
+Replacement markers can optionally specify a regular expression which will be
+used to decide whether a path segment should match the marker. To specify
+that a replacement marker should match only a specific set of characters as
+defined by a regular expression, you must use a slightly extended form of
+replacement marker syntax. Within braces, the replacement marker name must
+be followed by a colon, then directly thereafter, the regular expression.
+For example, under the hood, the replacement marker ``{foo}`` can more
+verbosely be spelled as ``{foo:[^/]+}``. The *default* regular expression
+associated with a replacement marker ``[^/]+`` matches one or more characters
+which are not a slash. You can use an arbitrary regular expression here to
+match a sequence of characters.
+
It is possible to use two replacement markers without any literal characters
between them, for instance ``/{foo}{bar}``. However, this would be a
nonsensical pattern without specifying a custom regular expression to
Please sign in to comment.
Something went wrong with that request. Please try again.