Reviewed-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
On 12/30/2013 12:17 AM, lvroyce(a)linux.vnet.ibm.com wrote:
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
Add support for passing params for GET method,
we will call it like:
GET /vms?state=running
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/controller.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/controller.py b/src/kimchi/controller.py
index 2940278..c99a811 100644
--- a/src/kimchi/controller.py
+++ b/src/kimchi/controller.py
@@ -71,6 +71,10 @@ def mime_in_header(header, mime):
def parse_request():
+ method = validate_method(('GET', 'DELETE', 'PUT',
'POST'))
+ if method == 'GET':
+ return cherrypy.request.params
+
if 'Content-Length' not in cherrypy.request.headers:
return {}
rawbody = cherrypy.request.body.read()
@@ -274,8 +278,9 @@ class Collection(object):
def _get_resources(self):
try:
+ params = parse_request()
get_list = getattr(self.model, model_fn(self, 'get_list'))
- idents = get_list(*self.model_args)
+ idents = get_list(*self.model_args, **params)
res_list = []
for ident in idents:
# internal text, get_list changes ident to unicode for sorted
@@ -302,7 +307,7 @@ class Collection(object):
return kimchi.template.render(get_class_name(self), data)
@cherrypy.expose
- def index(self, *args):
+ def index(self, *args, **kwargs):
method = validate_method(('GET', 'POST'))
if method == 'GET':
try: