From c0e6e69eb75ae042f0db3b98a5e064a94235837a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 29 Aug 2011 13:11:45 -0400 Subject: add match_param to the narrative docs --- docs/narr/viewconfig.rst | 19 +++++++++++++++++++ pyramid/config/views.py | 9 +++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/docs/narr/viewconfig.rst b/docs/narr/viewconfig.rst index a1b12ad2a..26cca2ad1 100644 --- a/docs/narr/viewconfig.rst +++ b/docs/narr/viewconfig.rst @@ -304,6 +304,25 @@ configured view. If ``request_param`` is not supplied, the view will be invoked without consideration of keys and values in the ``request.params`` dictionary. +``match_param`` + .. note:: This feature is new as of :app:`Pyramid` 1.2. + + This param may be either a single string of the format "key=value" or a + dict of key/value pairs. + + This argument ensures that the view will only be called when the + :term:`request` has key/value pairs in its :term:`matchdict` that equal + those supplied in the predicate. e.g. ``match_param="action=edit" would + require the ``action`` parameter in the :term:`matchdict` match the right + hande side of the expression (``edit``) for the view to "match" the current + request. + + If the ``match_param`` is a dict, every key/value pair must match for the + predicate to pass. + + If ``match_param`` is not supplied, the view will be invoked without + consideration of the keys and values in ``request.matchdict``. + ``containment`` This value should be a reference to a Python class or :term:`interface` that a parent object in the context resource's :term:`lineage` must provide diff --git a/pyramid/config/views.py b/pyramid/config/views.py index 06d6e901e..7e657905a 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -786,11 +786,12 @@ class ViewsConfiguratorMixin(object): or a dict of key/value pairs. A view declaration with this argument ensures that the view will - only be called when the :term:`request` has key/value pairs in - the ``matchdict`` that equal those supplied in the predicate. + only be called when the :term:`request` has key/value pairs in its + :term:`matchdict` that equal those supplied in the predicate. e.g. ``match_param="action=edit" would require the ``action`` - parameter in the ``matchdict`` match the right hande side of the - expression (``edit``) for the view to "match" the current request. + parameter in the :term:`matchdict` match the right hande side of + the expression (``edit``) for the view to "match" the current + request. If the ``match_param`` is a dict, every key/value pair must match for the predicate to pass. -- cgit v1.2.3