summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-08-02 14:46:03 -0400
committerChris McDonough <chrism@plope.com>2013-08-02 14:46:03 -0400
commit49f7c34024d5d3f483b9627790d9dc8a5b15e6a0 (patch)
treee413a5108ea941a991f027dfba258a8837f99235
parent12380ff2e21070fe63976fef08b90326428b7792 (diff)
downloadpyramid-49f7c34024d5d3f483b9627790d9dc8a5b15e6a0.tar.gz
pyramid-49f7c34024d5d3f483b9627790d9dc8a5b15e6a0.tar.bz2
pyramid-49f7c34024d5d3f483b9627790d9dc8a5b15e6a0.zip
add a docstring for not_
-rw-r--r--pyramid/config/util.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/pyramid/config/util.py b/pyramid/config/util.py
index a98e71cf5..892592196 100644
--- a/pyramid/config/util.py
+++ b/pyramid/config/util.py
@@ -29,6 +29,40 @@ def as_sorted_tuple(val):
return val
class not_(object):
+ """
+
+ 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.config.Configurator.add_route`
+
+ - :meth:`pyramid.config.Configurator.add_subscriber`
+
+ - :meth:`pyramid.view.view_config`
+
+ - :meth:`pyramid.events.subscriber`
+
+ .. versionadded:: 1.5
+ """
def __init__(self, value):
self.value = value