From 208ee5a8d6409bcdce361009dee6a2e335de1679 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 15 Jul 2010 17:41:05 +0000 Subject: 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``. --- repoze/bfg/zcml.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'repoze/bfg/zcml.py') 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="', + 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, -- cgit v1.2.3