diff options
author | Ryan Petrello <lists@ryanpetrello.com> | 2015-05-11 09:48:53 -0700 |
---|---|---|
committer | Ryan Petrello <lists@ryanpetrello.com> | 2015-05-21 13:04:23 -0700 |
commit | 3c634de56666cfadf19b813dd9de4e7e66b6ac65 (patch) | |
tree | 7904fe53270a27f3f4118908df04f171e3bca07f /pecan/routing.py | |
parent | 26d1d59aec72d3123cbff8dc929f200a198457fb (diff) | |
download | pecan-3c634de56666cfadf19b813dd9de4e7e66b6ac65.tar.gz |
Properly raise HTTP 405 (and specify Allow headers) for RestController
Change-Id: Id790efc75c8207eb61d74e9b2242b310ccd62ab1
Depends-On: Ieffa3fddc3c8d3152742455ca46d69bcc7208d69
Closes-bug: #1334690
Closes-bug: #1450109
Diffstat (limited to 'pecan/routing.py')
-rw-r--r-- | pecan/routing.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/pecan/routing.py b/pecan/routing.py index 1d534aa..91c9fe3 100644 --- a/pecan/routing.py +++ b/pecan/routing.py @@ -49,7 +49,10 @@ def lookup_controller(obj, remainder, request=None): request) handle_security(obj) return obj, remainder - except (exc.HTTPNotFound, PecanNotFound): + except (exc.HTTPNotFound, exc.HTTPMethodNotAllowed, + PecanNotFound) as e: + if isinstance(e, PecanNotFound): + e = exc.HTTPNotFound() while notfound_handlers: name, obj, remainder = notfound_handlers.pop() if name == '_default': @@ -67,11 +70,11 @@ def lookup_controller(obj, remainder, request=None): remainder == [''] and len(obj._pecan['argspec'].args) > 1 ): - raise exc.HTTPNotFound + raise e obj_, remainder_ = result return lookup_controller(obj_, remainder_, request) else: - raise exc.HTTPNotFound + raise e def handle_lookup_traversal(obj, args): |