Resolve a bug in _default handlers used in RestController.
Fixes-bug: 1233258 Change-Id: I5494cf4fc607cdc6833733dc1bf4022daa4c262e
This commit is contained in:
@@ -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':
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user