[Kimchi-devel] [project-kimchi][PATCHv4 1/5] Support params for GET method

Aline Manera alinefm at linux.vnet.ibm.com
Mon Dec 30 19:01:21 UTC 2013


Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>

On 12/30/2013 12:17 AM, lvroyce at linux.vnet.ibm.com wrote:
> From: Royce Lv <lvroyce at 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 at 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:




More information about the Kimchi-devel mailing list