summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDomen Kožar <domen@dev.si>2013-12-12 21:14:10 +0100
committerDomen Kožar <domen@dev.si>2014-11-11 08:03:56 +0100
commitf10d1e8f9e7a8d65218b9fb09efe3b6fa9511bdd (patch)
treeedae2d1ed38a57f5dae026c326d7acd1e4b6988f
parent1b584cf8850e9c75694b0aee7501a49c9c70de63 (diff)
downloadpyramid-f10d1e8f9e7a8d65218b9fb09efe3b6fa9511bdd.tar.gz
pyramid-f10d1e8f9e7a8d65218b9fb09efe3b6fa9511bdd.tar.bz2
pyramid-f10d1e8f9e7a8d65218b9fb09efe3b6fa9511bdd.zip
if view argument is not passed to config.add_notfound_view, use default_exceptionresponse_view
-rw-r--r--pyramid/config/views.py7
-rw-r--r--pyramid/tests/test_config/test_views.py15
2 files changed, 22 insertions, 0 deletions
diff --git a/pyramid/config/views.py b/pyramid/config/views.py
index 5ca696069..fbe7fc712 100644
--- a/pyramid/config/views.py
+++ b/pyramid/config/views.py
@@ -53,6 +53,7 @@ from pyramid.exceptions import (
from pyramid.httpexceptions import (
HTTPForbidden,
HTTPNotFound,
+ default_exceptionresponse_view,
)
from pyramid.registry import (
@@ -1671,6 +1672,9 @@ class ViewsConfiguratorMixin(object):
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
@@ -1697,6 +1701,9 @@ class ViewsConfiguratorMixin(object):
% arg
)
+ if not view:
+ view = default_exceptionresponse_view
+
settings = dict(
view=view,
context=HTTPNotFound,
diff --git a/pyramid/tests/test_config/test_views.py b/pyramid/tests/test_config/test_views.py
index a0d9ee0c3..0fb7c734a 100644
--- a/pyramid/tests/test_config/test_views.py
+++ b/pyramid/tests/test_config/test_views.py
@@ -1860,6 +1860,21 @@ class TestViewsConfigurationMixin(unittest.TestCase):
result = view(None, request)
self.assertEqual(result, (None, request))
+ def test_add_notfound_view_no_view_argument(self):
+ from zope.interface import implementedBy
+ from pyramid.interfaces import IRequest
+ from pyramid.httpexceptions import HTTPNotFound
+ config = self._makeOne(autocommit=True)
+ config.setup_registry()
+ config.add_notfound_view()
+ request = self._makeRequest(config)
+ view = self._getViewCallable(config,
+ ctx_iface=implementedBy(HTTPNotFound),
+ request_iface=IRequest)
+ context = HTTPNotFound()
+ result = view(context, request)
+ self.assertEqual(result, context)
+
def test_add_notfound_view_allows_other_predicates(self):
from pyramid.renderers import null_renderer
config = self._makeOne(autocommit=True)