summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2010-06-30 17:24:23 +0000
committerChris McDonough <chrism@agendaless.com>2010-06-30 17:24:23 +0000
commit23ab84757a4d216a7c5eea77e85aedfd3a9400ca (patch)
tree2c1718d303af84f09103603e0d8b2c3f8c1a446d
parent44bc118a61e2e9d93a65b8edd5be9118fb478741 (diff)
downloadpyramid-23ab84757a4d216a7c5eea77e85aedfd3a9400ca.tar.gz
pyramid-23ab84757a4d216a7c5eea77e85aedfd3a9400ca.tar.bz2
pyramid-23ab84757a4d216a7c5eea77e85aedfd3a9400ca.zip
pass only match and route and document route minimally
-rw-r--r--CHANGES.txt14
-rw-r--r--repoze/bfg/urldispatch.py5
2 files changed, 13 insertions, 6 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 8eb1b57c7..3c1b35a6a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -17,11 +17,10 @@ Features
always ``None``.
As of this release, the first argument passed to a predicate is now
- a dictionary conventionally named ``info`` consisting of ``match``,
- ``route``, and ``mapper``. ``match`` is a dictionary: it represents
- the arguments matched in the URL by the route. ``route`` is an
- object representing the route that matched. ``mapper`` is the url
- dispatch route mapper object.
+ a dictionary conventionally named ``info`` consisting of ``route``,
+ and ``match``. ``match`` is a dictionary: it represents the
+ arguments matched in the URL by the route. ``route`` is an object
+ representing the route which was matched.
This is useful when predicates need access to the route match. For
example::
@@ -30,11 +29,16 @@ Features
def predicate(info, request):
if info['match'][segment_name] in args:
return True
+ return predicate
num_one_two_or_three = any_of('num, 'one', 'two', 'three')
add_route('/:num', custom_predicates=(num_one_two_or_three,))
+ The ``route`` object is an object that has two useful attributes:
+ ``name`` and ``path``. The ``name`` attribute is the route name.
+ The ``path`` attribute is the route pattern.
+
Documentation
-------------
diff --git a/repoze/bfg/urldispatch.py b/repoze/bfg/urldispatch.py
index 458f1a7a5..51b6f9f84 100644
--- a/repoze/bfg/urldispatch.py
+++ b/repoze/bfg/urldispatch.py
@@ -51,7 +51,10 @@ class RoutesMapper(object):
match = route.match(path)
if match is not None:
preds = route.predicates
- info = {'route':route, 'match':match}
+ # NB: it is the intent that only 'match' be relied on
+ # by built-in predicates. 'route' and 'mapper' may be
+ # used by custom predicates.
+ info = {'match':match, 'route':route}
if preds and not all((p(info, request) for p in preds)):
continue
return info