summaryrefslogtreecommitdiff
path: root/pecan/routing.py
diff options
context:
space:
mode:
authorRyan Petrello <lists@ryanpetrello.com>2015-05-11 09:48:53 -0700
committerRyan Petrello <lists@ryanpetrello.com>2015-05-21 13:04:23 -0700
commit3c634de56666cfadf19b813dd9de4e7e66b6ac65 (patch)
tree7904fe53270a27f3f4118908df04f171e3bca07f /pecan/routing.py
parent26d1d59aec72d3123cbff8dc929f200a198457fb (diff)
downloadpecan-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.py9
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):