summaryrefslogtreecommitdiff
path: root/repoze/bfg/zcml.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2010-07-15 17:41:05 +0000
committerChris McDonough <chrism@agendaless.com>2010-07-15 17:41:05 +0000
commit208ee5a8d6409bcdce361009dee6a2e335de1679 (patch)
tree3e47bda8becf94ae96d4b705c410fd8a2a925ffb /repoze/bfg/zcml.py
parent6ef5b21bffe62c3ad6d276b36ba4229f681128ba (diff)
downloadpyramid-208ee5a8d6409bcdce361009dee6a2e335de1679.tar.gz
pyramid-208ee5a8d6409bcdce361009dee6a2e335de1679.tar.bz2
pyramid-208ee5a8d6409bcdce361009dee6a2e335de1679.zip
Features
-------- - New view predicate: match_val. The ``match_val`` value represents the presence of a value in the structure added to the request named ``matchdict`` during URL dispatch representing the match values from the route pattern (e.g. if the route pattern has ``:foo`` in it, and the route matches, a key will exist in the matchdict named ``foo``). Like all other view predicates, this feature is exposed via the ``bfg_view`` API, the Configurator ``add_view`` API, and the ZCML ``view`` directive. Documentation ------------- - API documentation for the ``add_view`` method of the configurator changed to include ``match_val``. - ZCML documentation for ``view`` ZCML directive changed to include ``match_val``. - The ``Views`` narrative chapter now contains a description of the ``match_val`` predicate. Bug Fixes --------- - The ``header`` predicate (when used as either a view predicate or a route predicate) had a problem when specified with a name/regex pair. When the header did not exist in the headers dictionary, the regex match could be fed ``None``, causing it to throw a ``TypeError: expected string or buffer`` exception. Now, the predicate returns False as intended. Internal -------- - Remove ``repoze.bfg.configuration.isclass`` function in favor of using ``inspect.isclass``.
Diffstat (limited to 'repoze/bfg/zcml.py')
-rw-r--r--repoze/bfg/zcml.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py
index d55dd1d1d..b8ca9eb21 100644
--- a/repoze/bfg/zcml.py
+++ b/repoze/bfg/zcml.py
@@ -141,6 +141,11 @@ class IViewDirective(Interface):
description=(u'Accepts a regular expression.'),
required = False)
+ match_val = TextLine(
+ title=u'Matchdict name/value pair in the form "name=<regex>"',
+ description=u'Regular expression matching for matchdict values',
+ required = False)
+
custom_predicates = Tokens(
title=u"One or more custom dotted names to custom predicate callables",
description=(u"A list of dotted name references to callables that "
@@ -168,6 +173,7 @@ def view(
accept=None,
header=None,
path_info=None,
+ match_val=None,
custom_predicates=(),
context=None,
cacheable=True, # not used, here for b/w compat < 0.8
@@ -199,7 +205,8 @@ def view(
request_method=request_method, request_param=request_param,
containment=containment, attr=attr, renderer=renderer,
wrapper=wrapper, xhr=xhr, accept=accept, header=header,
- path_info=path_info, custom_predicates=custom_predicates,
+ path_info=path_info, match_val=match_val,
+ custom_predicates=custom_predicates,
_info=_context.info)
discriminator = ['view', context, name, request_type, IView, containment,