diff options
Diffstat (limited to 'pecan/routing.py')
-rw-r--r-- | pecan/routing.py | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/pecan/routing.py b/pecan/routing.py index d38c22e..a7a6d4f 100644 --- a/pecan/routing.py +++ b/pecan/routing.py @@ -1,3 +1,5 @@ +import warnings + from webob import exc from secure import handle_security, cross_boundary @@ -42,25 +44,30 @@ def lookup_controller(obj, url_path): else: # Notfound handler is an internal redirect, so continue # traversal - try: - result = obj(*remainder) - if result: - prev_obj = obj - obj, remainder = result - # crossing controller boundary - cross_boundary(prev_obj, obj) - break - except TypeError, te: - import warnings - msg = 'Got exception calling lookup(): %s (%s)' - warnings.warn( - msg % (te, te.args), - RuntimeWarning - ) + result = handle_lookup_traversal(obj, remainder) + if result: + return lookup_controller(*result) else: raise exc.HTTPNotFound +def handle_lookup_traversal(obj, args): + try: + result = obj(*args) + if result: + prev_obj = obj + obj, remainder = result + # crossing controller boundary + cross_boundary(prev_obj, obj) + return result + except TypeError as te: + msg = 'Got exception calling lookup(): %s (%s)' + warnings.warn( + msg % (te, te.args), + RuntimeWarning + ) + + def find_object(obj, remainder, notfound_handlers): ''' 'Walks' the url path in search of an action for which a controller is |