summaryrefslogtreecommitdiff
path: root/pecan/routing.py
diff options
context:
space:
mode:
authorRyan Petrello <lists@ryanpetrello.com>2014-09-23 13:30:00 -0400
committerRyan Petrello <lists@ryanpetrello.com>2014-09-26 10:46:31 -0400
commit960d83971c712e98c45c830df84fdc61cb8cd15b (patch)
tree301e0ec5a8f870a55f713a6ea8f46b39dc01a8e0 /pecan/routing.py
parent921a8b77dcb11d4e3668bf23a5731b665b748a92 (diff)
downloadpecan-960d83971c712e98c45c830df84fdc61cb8cd15b.tar.gz
Fix a routing bug for generic subcontrollers.
Change-Id: I3764da98f19f02c1f28a29377c6d24238d869930 Fixes-bug: 1361728
Diffstat (limited to 'pecan/routing.py')
-rw-r--r--pecan/routing.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/pecan/routing.py b/pecan/routing.py
index 7acff76..58a74c6 100644
--- a/pecan/routing.py
+++ b/pecan/routing.py
@@ -3,7 +3,7 @@ import warnings
from webob import exc
from .secure import handle_security, cross_boundary
-from .util import iscontroller, getargspec
+from .util import iscontroller, getargspec, _cfg
__all__ = ['lookup_controller', 'find_object']
@@ -148,6 +148,17 @@ def find_object(obj, remainder, notfound_handlers, request):
if not remainder:
raise PecanNotFound
+
+ prev_remainder = remainder
prev_obj = obj
remainder = rest
obj = getattr(obj, next_obj, None)
+
+ # Last-ditch effort: if there's not a matching subcontroller, no
+ # `_default`, no `_lookup`, and no `_route`, look to see if there's
+ # an `index` that has a generic method defined for the current request
+ # method.
+ if not obj and not notfound_handlers and hasattr(prev_obj, 'index'):
+ if request.method in _cfg(prev_obj.index).get('generic_handlers',
+ {}):
+ return prev_obj.index, prev_remainder