From 49f7c34024d5d3f483b9627790d9dc8a5b15e6a0 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 2 Aug 2013 14:46:03 -0400 Subject: add a docstring for not_ --- pyramid/config/util.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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 -- cgit v1.2.3