diff options
| author | Chris McDonough <chrism@agendaless.com> | 2010-06-30 02:47:16 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2010-06-30 02:47:16 +0000 |
| commit | 44bc118a61e2e9d93a65b8edd5be9118fb478741 (patch) | |
| tree | 2ecc1bf62e7a1cd06ac303228c9f6f7be6d3caa2 /CHANGES.txt | |
| parent | fc80bdfeff567a16304721d5af3b80a38121a44d (diff) | |
| download | pyramid-44bc118a61e2e9d93a65b8edd5be9118fb478741.tar.gz pyramid-44bc118a61e2e9d93a65b8edd5be9118fb478741.tar.bz2 pyramid-44bc118a61e2e9d93a65b8edd5be9118fb478741.zip | |
- In earlier versions, a custom route predicate associated with a url
dispatch route (each of the predicate functions fed to the
``custom_predicates`` argument of
``repoze.bfg.configuration.Configurator.add_route``) has always
required a 2-positional argument signature, e.g. ``(context,
request)``. Before this release, the ``context`` argument was
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.
This is useful when predicates need access to the route match. For
example::
def any_of(segment_name, *args):
def predicate(info, request):
if info['match'][segment_name] in args:
return True
num_one_two_or_three = any_of('num, 'one', 'two', 'three')
add_route('/:num', custom_predicates=(num_one_two_or_three,))
Diffstat (limited to 'CHANGES.txt')
| -rw-r--r-- | CHANGES.txt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 65690e73e..8eb1b57c7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,33 @@ Features ``repoze.bfg.paster.BFGShellCommand`` hookable in cases where endware may interfere with the default versions. +- In earlier versions, a custom route predicate associated with a url + dispatch route (each of the predicate functions fed to the + ``custom_predicates`` argument of + ``repoze.bfg.configuration.Configurator.add_route``) has always + required a 2-positional argument signature, e.g. ``(context, + request)``. Before this release, the ``context`` argument was + 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. + + This is useful when predicates need access to the route match. For + example:: + + def any_of(segment_name, *args): + def predicate(info, request): + if info['match'][segment_name] in args: + return True + + num_one_two_or_three = any_of('num, 'one', 'two', 'three') + + add_route('/:num', custom_predicates=(num_one_two_or_three,)) + Documentation ------------- |
