add docs to notfound_view_config decorator code, expand docs to inlcude an example
| | |
| | | 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: |
| | |
| | | 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. |
| | | |
| | | """ |