diff options
author | Ryan Petrello <lists@ryanpetrello.com> | 2013-05-07 11:53:46 -0400 |
---|---|---|
committer | Ryan Petrello <lists@ryanpetrello.com> | 2013-05-07 11:53:46 -0400 |
commit | 3f0e68c4709d02d2936f54557e2030933bdd4313 (patch) | |
tree | 71b3f9be84895eb4458237982f56e389c2affe6e /pecan/routing.py | |
parent | 51f7b20abe4c2c5db8fad183be37c9ade831d7a6 (diff) | |
parent | e985be86ae89eccfe3c344196112b31a265ab741 (diff) | |
download | pecan-3f0e68c4709d02d2936f54557e2030933bdd4313.tar.gz |
Merge remote-tracking branch 'origin/next' into py3k
Conflicts:
pecan/rest.py
pecan/routing.py
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 8ebd7a9..31cbf92 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 as 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 |