summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Petrello <lists@ryanpetrello.com>2013-09-30 16:23:18 -0400
committerRyan Petrello <lists@ryanpetrello.com>2013-09-30 16:51:22 -0400
commit8287f6a81bc5ebe611be9837e88d2793087fbcf7 (patch)
treee3d2897d38feaa24048cdff40eeec3371bfdf4fd
parent55075fb8cf58b0c4ba029cd097232118b079185c (diff)
downloadpecan-8287f6a81bc5ebe611be9837e88d2793087fbcf7.tar.gz
Resolve a bug in `_default` handlers used in `RestController`.
Fixes-bug: 1233258 Change-Id: I5494cf4fc607cdc6833733dc1bf4022daa4c262e
-rw-r--r--pecan/routing.py2
-rw-r--r--pecan/tests/test_rest.py17
2 files changed, 18 insertions, 1 deletions
diff --git a/pecan/routing.py b/pecan/routing.py
index 47eb354..ca8c93f 100644
--- a/pecan/routing.py
+++ b/pecan/routing.py
@@ -36,7 +36,7 @@ def lookup_controller(obj, remainder):
obj, remainder = find_object(obj, remainder, notfound_handlers)
handle_security(obj)
return obj, remainder
- except PecanNotFound:
+ except (exc.HTTPNotFound, PecanNotFound):
while notfound_handlers:
name, obj, remainder = notfound_handlers.pop()
if name == '_default':
diff --git a/pecan/tests/test_rest.py b/pecan/tests/test_rest.py
index c1f8acc..f53030a 100644
--- a/pecan/tests/test_rest.py
+++ b/pecan/tests/test_rest.py
@@ -1057,6 +1057,23 @@ class TestRestController(PecanTestCase):
assert r.status_int == 200
assert r.body == b_('POST-2')
+ def test_nested_rest_with_default(self):
+
+ class FooController(RestController):
+
+ @expose()
+ def _default(self, *remainder):
+ return "DEFAULT %s" % remainder
+
+ class RootController(RestController):
+ foo = FooController()
+
+ app = TestApp(make_app(RootController()))
+
+ r = app.get('/foo/missing')
+ assert r.status_int == 200
+ assert r.body == b_("DEFAULT missing")
+
def test_dynamic_rest_lookup(self):
class BarController(RestController):
@expose()