summaryrefslogtreecommitdiff
path: root/docs/narr
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-07-24 17:22:48 -0400
committerChris McDonough <chrism@plope.com>2013-07-24 17:22:48 -0400
commit32333e4d84fe0e71ce097a5dca57025353956dbe (patch)
treec9814e4b80b1b1c215156885559e2744eebf5c87 /docs/narr
parentd79c0338e6b87ffa657f91065ce73c752f60a0b8 (diff)
downloadpyramid-32333e4d84fe0e71ce097a5dca57025353956dbe.tar.gz
pyramid-32333e4d84fe0e71ce097a5dca57025353956dbe.tar.bz2
pyramid-32333e4d84fe0e71ce097a5dca57025353956dbe.zip
add not_ predicate feature
Diffstat (limited to 'docs/narr')
-rw-r--r--docs/narr/viewconfig.rst27
1 files changed, 27 insertions, 0 deletions
diff --git a/docs/narr/viewconfig.rst b/docs/narr/viewconfig.rst
index 241ce62b5..388371a0d 100644
--- a/docs/narr/viewconfig.rst
+++ b/docs/narr/viewconfig.rst
@@ -557,6 +557,33 @@ form of :term:`declarative configuration`, while
:meth:`pyramid.config.Configurator.add_view` is a form of :term:`imperative
configuration`. However, they both do the same thing.
+Inverting Predicate Values
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You can invert the meaning of any predicate value by wrapping it in a call to
+:class:`pyramid.config.not_`.
+
+.. code-block:: python
+ :linenos:
+
+ from pyramid.config import not_
+
+ config.add_view(
+ 'mypackage.views.my_view',
+ route_name='ok',
+ request_method=not_('POST')
+ )
+
+The above example will ensure that the view is called if the request method
+is *not* ``POST``, at least if no other view is more specific.
+
+This technique of wrapping a predicate value in ``not_`` can be used anywhere
+predicate values are accepted:
+
+- :meth:`pyramid.config.Configurator.add_view`
+
+- :meth:`pyramid.view.view_config`
+
.. index::
single: view_config placement