Chris McDonough
2015-03-15 24358c9d1d474bb81ce423d270041464bc731ce9
add docs to notfound_view_config decorator code, expand  docs to inlcude an example
2 files modified
45 ■■■■■ changed files
pyramid/config/views.py 20 ●●●● patch | view | raw | blame | history
pyramid/view.py 25 ●●●●● patch | view | raw | blame | history
pyramid/config/views.py
@@ -1703,11 +1703,25 @@
        Pyramid will return the result of the view callable provided as
        ``view``, as normal.
        If ``append_slash`` implements IResponse then that will be used as the
        response class instead of the default of ``HTTPFound``.
        If the argument provided as ``append_slash`` is not a boolean but
        instead implements :class:`~pyramid.interfaces.IResponse`, the
        append_slash logic will behave as if ``append_slash=True`` was passed,
        but the provided class will be used as the response class instead of
        the default :class:`~pyramid.httpexceptions.HTTPFound` response class
        when a redirect is performed.  For example:
        .. versionadded:: 1.3
          .. code-block:: python
            from pyramid.httpexceptions import HTTPMovedPermanently
            config.add_notfound_view(append_slash=HTTPMovedPermanently)
        The above means that a redirect to a slash-appended route will be
        attempted, but instead of :class:`~pyramid.httpexceptions.HTTPFound`
        being used, :class:`~pyramid.httpexceptions.HTTPMovedPermanently will
        be used` for the redirect response if a slash-appended route is found.
        .. versionchanged:: 1.6
        .. versionadded:: 1.3
        """
        for arg in ('name', 'permission', 'context', 'for_', 'http_cache'):
            if arg in predicates:
pyramid/view.py
@@ -332,6 +332,31 @@
    redirect to the URL implied by the route; if it does not, Pyramid will
    return the result of the view callable provided as ``view``, as normal.
    If the argument provided as ``append_slash`` is not a boolean but
    instead implements :class:`~pyramid.interfaces.IResponse`, the
    append_slash logic will behave as if ``append_slash=True`` was passed,
    but the provided class will be used as the response class instead of
    the default :class:`~pyramid.httpexceptions.HTTPFound` response class
    when a redirect is performed.  For example:
      .. code-block:: python
        from pyramid.httpexceptions import (
            HTTPMovedPermanently,
            HTTPNotFound
            )
        @notfound_view_config(append_slash=HTTPMovedPermanently)
        def aview(request):
            return HTTPNotFound('not found')
    The above means that a redirect to a slash-appended route will be
    attempted, but instead of :class:`~pyramid.httpexceptions.HTTPFound`
    being used, :class:`~pyramid.httpexceptions.HTTPMovedPermanently will
    be used` for the redirect response if a slash-appended route is found.
    .. versionchanged:: 1.6
    See :ref:`changing_the_notfound_view` for detailed usage information.
    """