summaryrefslogtreecommitdiff
path: root/pecan/rest.py
diff options
context:
space:
mode:
authorYoann Roman <yoann@shootq.com>2011-01-21 11:22:03 -0500
committerYoann Roman <yoann@shootq.com>2011-01-21 11:22:03 -0500
commit1c6fce95389d9154225ea05ef5591b850a9893d5 (patch)
tree4fe4427dda3013fe40696b4de4d8d63a7b49fefb /pecan/rest.py
parent0241fd513e4cd76bbc5f36ac8d54ecce207724ef (diff)
downloadpecan-1c6fce95389d9154225ea05ef5591b850a9893d5.tar.gz
Standardizing storage of request metadata on request object
Diffstat (limited to 'pecan/rest.py')
-rw-r--r--pecan/rest.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/pecan/rest.py b/pecan/rest.py
index edb9e62..f35cdea 100644
--- a/pecan/rest.py
+++ b/pecan/rest.py
@@ -66,12 +66,12 @@ class RestController(object):
for i, item in enumerate(remainder):
controller = getattr(self, item, None)
if controller and not ismethod(controller):
- request.context.setdefault('routing_args', []).extend(remainder[:i])
+ self._set_routing_args(remainder[:i])
return lookup_controller(controller, remainder[i + 1:])
elif fixed_args < len(remainder) and hasattr(self, remainder[fixed_args]):
controller = getattr(self, remainder[fixed_args])
if not ismethod(controller):
- request.context.setdefault('routing_args', []).extend(remainder[:fixed_args])
+ self._set_routing_args(remainder[:fixed_args])
return lookup_controller(controller, remainder[fixed_args + 1:])
def _handle_custom(self, method, remainder):
@@ -165,3 +165,9 @@ class RestController(object):
abort(404)
_handle_put = _handle_post
+
+ def _set_routing_args(self, args):
+ if hasattr(request, 'routing_args'):
+ request.routing_args.extend(args)
+ else:
+ setattr(request, 'routing_args', args)