diff options
| author | Chris McDonough <chrism@plope.com> | 2013-09-02 01:03:02 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2013-09-02 01:03:02 -0400 |
| commit | aa7b06b946b4e8e66818da29e64e9cbccb6ccb10 (patch) | |
| tree | 7360aa9270f297adbb8307a2940b87b7bdf1cfe5 | |
| parent | dd9bc8a9ac82b7e8ec36401ee6def121a95b060c (diff) | |
| download | pyramid-aa7b06b946b4e8e66818da29e64e9cbccb6ccb10.tar.gz pyramid-aa7b06b946b4e8e66818da29e64e9cbccb6ccb10.tar.bz2 pyramid-aa7b06b946b4e8e66818da29e64e9cbccb6ccb10.zip | |
move docs section to a more appropriate place
| -rw-r--r-- | docs/narr/viewconfig.rst | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/docs/narr/viewconfig.rst b/docs/narr/viewconfig.rst index e09fd83ab..76cf1daac 100644 --- a/docs/narr/viewconfig.rst +++ b/docs/narr/viewconfig.rst @@ -465,6 +465,36 @@ configured view. .. versionadded:: 1.4a1 +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` + +.. versionadded:: 1.5 + + .. index:: single: view_config decorator @@ -557,35 +587,6 @@ 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` - -.. versionadded:: 1.5 - .. index:: single: view_config placement |
