'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
view cannot be found for the request).  The simplest example is:
.. code-block:: python
def notfound(request):
return Response(\'Not Found\', status=\'404 Not Found\')
config.add_notfound_view(notfound)
If ``view`` argument is not provided, the view callable defaults to
:func:`~pyramid.httpexceptions.default_exceptionresponse_view`.
All arguments except ``append_slash`` have the same meaning as
:meth:`pyramid.config.Configurator.add_view` and each predicate
argument restricts the set of circumstances under which this notfound
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
argument values make no sense in the context of a Not Found View.
If ``append_slash`` is ``True``, when this Not Found View is invoked,
and the current path info does not end in a slash, the notfound logic
will attempt to find a :term:`route` that matches the request\'s path
info suffixed with a slash.  If such a route exists, Pyramid will
issue a 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
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.
.. versionadded:: 1.3
.. versionchanged:: 1.6
The ``append_slash`` argument was modified to allow any object that
implements the ``IResponse`` interface to specify the response class
used when a redirect is performed.
.. versionchanged:: 1.8
The view is created using ``exception_only=True``.'

@viewdefaults
@action_method
def add_notfound_view(self, view=None, attr=None, renderer=None, wrapper=None, route_name=None, request_type=None, request_method=None, request_param=None, containment=None, xhr=None, accept=None, header=None, path_info=None, custom_predicates=(), decorator=None, mapper=None, match_param=None, append_slash=False, **view_options):

    for arg in ('name', 'permission', 'context', 'for_', 'require_csrf', 'exception_only'):
        if (arg in view_options):
            raise ConfigurationError(('%s    may    not    be    used    as    an    argument    to    add_notfound_view' % (arg,)))
    if (view is None):
        view = default_exceptionresponse_view
    settings = dict(view=view, context=HTTPNotFound, exception_only=True, wrapper=wrapper, request_type=request_type, request_method=request_method, request_param=request_param, containment=containment, xhr=xhr, accept=accept, header=header, path_info=path_info, custom_predicates=custom_predicates, decorator=decorator, mapper=mapper, match_param=match_param, route_name=route_name, permission=NO_PERMISSION_REQUIRED, require_csrf=False)
    settings.update(view_options)
    if append_slash:
        view = self._derive_view(view, attr=attr, renderer=renderer)
        if IResponse.implementedBy(append_slash):
            view = AppendSlashNotFoundViewFactory(view, redirect_class=append_slash)
        else:
            view = AppendSlashNotFoundViewFactory(view)
        settings['view'] = view
    else:
        settings['attr'] = attr
        settings['renderer'] = renderer
    return self.add_view(**settings)
