diff options
| -rw-r--r-- | docs/narr/viewconfig.rst | 10 | ||||
| -rw-r--r-- | docs/narr/views.rst | 6 | ||||
| -rw-r--r-- | pyramid/config/views.py | 22 | ||||
| -rw-r--r-- | pyramid/view.py | 6 |
4 files changed, 22 insertions, 22 deletions
diff --git a/docs/narr/viewconfig.rst b/docs/narr/viewconfig.rst index 76eaf3cc5..7cb8e0306 100644 --- a/docs/narr/viewconfig.rst +++ b/docs/narr/viewconfig.rst @@ -307,8 +307,8 @@ configured view. interface; it is otherwise false. It is possible to pass an exception class as the context if your context may - subclass an exception. In this case **two** views will be registered. One - will match normal incoming requests and the other will match as an + subclass an exception. In this case *two* views will be registered. One + will match normal incoming requests, and the other will match as an :term:`exception view` which only occurs when an exception is raised during the normal request processing pipeline. @@ -317,11 +317,11 @@ configured view. ``exception_only`` - When this value is ``True`` the ``context`` argument must be a subclass of + When this value is ``True``, the ``context`` argument must be a subclass of ``Exception``. This flag indicates that only an :term:`exception view` should - be created and that this view should not match if the traversal + be created, and that this view should not match if the traversal :term:`context` matches the ``context`` argument. If the ``context`` is a - subclass of ``Exception`` and this value is ``False`` (the default) then a + subclass of ``Exception`` and this value is ``False`` (the default), then a view will be registered to match the traversal :term:`context` as well. .. versionadded:: 1.8 diff --git a/docs/narr/views.rst b/docs/narr/views.rst index 465062651..ab139ea19 100644 --- a/docs/narr/views.rst +++ b/docs/narr/views.rst @@ -262,13 +262,13 @@ specialized views as described in :ref:`special_exceptions_in_callables` can also be used by application developers to convert arbitrary exceptions to responses. -To register a :term:`exception view` that should be called whenever a +To register an :term:`exception view` that should be called whenever a particular exception is raised from within :app:`Pyramid` view code, use :meth:`pyramid.config.Configurator.add_exception_view` to register a view configuration which matches the exception (or a subclass of the exception) and points at a view callable for which you'd like to generate a response. The exception will be passed as the ``context`` argument to any -:term:`view predicate` registered with the view as well as to the view itself. +:term:`view predicate` registered with the view, as well as to the view itself. For convenience a new decorator exists, :class:`pyramid.views.exception_view_config`, which may be used to easily register exception views. @@ -334,7 +334,7 @@ which have a name will be ignored. In most cases, you should register an :term:`exception view` by using :meth:`pyramid.config.Configurator.add_exception_view`. However, it is - possible to register 'normal' (i.e., non-exception) views against a context + possible to register "normal" (i.e., non-exception) views against a context resource type which inherits from :exc:`Exception` (i.e., ``config.add_view(context=Exception)``). When the view configuration is processed, *two* views are registered. One as a "normal" view, the other diff --git a/pyramid/config/views.py b/pyramid/config/views.py index 0b025911e..acdc00704 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -502,19 +502,19 @@ class ViewsConfiguratorMixin(object): if the :term:`context` provides the represented interface; it is otherwise false. This argument may also be provided to ``add_view`` as ``for_`` (an older, still-supported - spelling). If the view should **only** match when handling - exceptions then set the ``exception_only`` to ``True``. + spelling). If the view should *only* match when handling + exceptions, then set the ``exception_only`` to ``True``. exception_only .. versionadded:: 1.8 - When this value is ``True`` the ``context`` argument must be + When this value is ``True``, the ``context`` argument must be a subclass of ``Exception``. This flag indicates that only an - :term:`exception view` should be created and that this view should + :term:`exception view` should be created, and that this view should not match if the traversal :term:`context` matches the ``context`` argument. If the ``context`` is a subclass of ``Exception`` and - this value is ``False`` (the default) then a view will be + this value is ``False`` (the default), then a view will be registered to match the traversal :term:`context` as well. route_name @@ -908,7 +908,7 @@ class ViewsConfiguratorMixin(object): # allow failure of registered template factories to be deferred # until view execution, like other bad renderer factories; if # we tried to relate this to an existing renderer factory - # without checking if it the factory actually existed, we'd end + # without checking if the factory actually existed, we'd end # up with a KeyError at startup time, which is inconsistent # with how other bad renderer registrations behave (they throw # a ValueError at view execution time) @@ -1458,7 +1458,7 @@ class ViewsConfiguratorMixin(object): view will be invoked. Unlike :meth:`pyramid.config.Configurator.add_view`, this method will raise an exception if passed ``name``, ``permission``, ``require_csrf``, - ``context``, ``for_`` or ``exception_only`` keyword arguments. These + ``context``, ``for_``, or ``exception_only`` keyword arguments. These argument values make no sense in the context of a forbidden :term:`exception view`. @@ -1534,7 +1534,7 @@ class ViewsConfiguratorMixin(object): ): """ Add a default :term:`Not Found View` to the current configuration state. The view will be called when Pyramid or application code raises - an :exc:`pyramid.httpexceptions.HTTPNotFound` exception (e.g. when a + an :exc:`pyramid.httpexceptions.HTTPNotFound` exception (e.g., when a view cannot be found for the request). The simplest example is: .. code-block:: python @@ -1656,11 +1656,11 @@ class ViewsConfiguratorMixin(object): the current configuration state. The view will be called when Pyramid or application code raises the given exception. - This method accepts accepts almost all of the same arguments as + This method accepts almost all of the same arguments as :meth:`pyramid.config.Configurator.add_view` except for ``name``, - ``permission``, ``for_``, ``require_csrf`` and ``exception_only``. + ``permission``, ``for_``, ``require_csrf``, and ``exception_only``. - By default, this method will set ``context=Exception`` thus + By default, this method will set ``context=Exception``, thus registering for most default Python exceptions. Any subclass of ``Exception`` may be specified. diff --git a/pyramid/view.py b/pyramid/view.py index 28318b750..498bdde45 100644 --- a/pyramid/view.py +++ b/pyramid/view.py @@ -480,7 +480,7 @@ class exception_view_config(object): and additionally accepts most of the same arguments as the constructor of :class:`pyramid.view.view_config`. It can be used in the same places, and behaves in largely the same way, except it always registers an - exception view instead of a 'normal' view that dispatches on the request + exception view instead of a "normal" view that dispatches on the request :term:`context`. Example: @@ -495,7 +495,7 @@ class exception_view_config(object): return {'error': str(request.exception)} All arguments passed to this function have the same meaning as - :meth:`pyramid.view.view_config` and each predicate argument restricts + :meth:`pyramid.view.view_config`, and each predicate argument restricts the set of circumstances under which this exception view will be invoked. """ @@ -521,7 +521,7 @@ class exception_view_config(object): if info.scope == 'class': # if the decorator was attached to a method in a class, or # otherwise executed at class scope, we need to set an - # 'attr' into the settings if one isn't already in there + # 'attr' in the settings if one isn't already in there if settings.get('attr') is None: settings['attr'] = wrapped.__name__ |
