From 80cd81f714ab6da60130f450f5c96ad279649871 Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Wed, 7 Mar 2012 21:55:56 -0800 Subject: [PATCH] Replaced use of webob.Request.str_param * Changed webob.Request.str_param => webob.Request.param to ensure compatibility with WebOb >= 1.2. * Fixes bug 949677 Change-Id: I59c5af17fdef0754862ef6a0fda99978036112d9 --- Authors | 1 + glance/api/v1/images.py | 8 ++++---- glance/registry/api/v1/images.py | 18 +++++++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Authors b/Authors index 0cb94800..28b803e7 100644 --- a/Authors +++ b/Authors @@ -33,6 +33,7 @@ Lorin Hochstein Major Hayden Mark McLoughlin Mark Washenberger +Maru Newby Matt Dietz Mike Lundy Monty Taylor diff --git a/glance/api/v1/images.py b/glance/api/v1/images.py index 9ad408e2..d8d9090f 100644 --- a/glance/api/v1/images.py +++ b/glance/api/v1/images.py @@ -187,8 +187,8 @@ class Controller(controller.BaseController): params = {'filters': self._get_filters(req)} for PARAM in SUPPORTED_PARAMS: - if PARAM in req.str_params: - params[PARAM] = req.str_params.get(PARAM) + if PARAM in req.params: + params[PARAM] = req.params.get(PARAM) return params def _get_filters(self, req): @@ -199,9 +199,9 @@ class Controller(controller.BaseController): :retval a dict of key/value filters """ query_filters = {} - for param in req.str_params: + for param in req.params: if param in SUPPORTED_FILTERS or param.startswith('property-'): - query_filters[param] = req.str_params.get(param) + query_filters[param] = req.params.get(param) if not filters.validate(param, query_filters[param]): raise HTTPBadRequest('Bad value passed to filter %s ' 'got %s' % (param, diff --git a/glance/registry/api/v1/images.py b/glance/registry/api/v1/images.py index a4a19d80..1c172da2 100644 --- a/glance/registry/api/v1/images.py +++ b/glance/registry/api/v1/images.py @@ -156,12 +156,12 @@ class Controller(object): else: filters['is_public'] = True - for param in req.str_params: + for param in req.params: if param in SUPPORTED_FILTERS: - filters[param] = req.str_params.get(param) + filters[param] = req.params.get(param) if param.startswith('property-'): _param = param[9:] - properties[_param] = req.str_params.get(param) + properties[_param] = req.params.get(param) if 'changes-since' in filters: isotime = filters['changes-since'] @@ -196,7 +196,7 @@ class Controller(object): def _get_limit(self, req): """Parse a limit query param into something usable.""" try: - limit = int(req.str_params.get('limit', + limit = int(req.params.get('limit', self.conf.limit_param_default)) except ValueError: raise exc.HTTPBadRequest(_("limit param must be an integer")) @@ -208,7 +208,7 @@ class Controller(object): def _get_marker(self, req): """Parse a marker query param into something usable.""" - marker = req.str_params.get('marker', None) + marker = req.params.get('marker', None) if marker and not utils.is_uuid_like(marker): msg = _('Invalid marker format') @@ -218,7 +218,7 @@ class Controller(object): def _get_sort_key(self, req): """Parse a sort key query param from the request object.""" - sort_key = req.str_params.get('sort_key', None) + sort_key = req.params.get('sort_key', None) if sort_key is not None and sort_key not in SUPPORTED_SORT_KEYS: _keys = ', '.join(SUPPORTED_SORT_KEYS) msg = _("Unsupported sort_key. Acceptable values: %s") % (_keys,) @@ -227,7 +227,7 @@ class Controller(object): def _get_sort_dir(self, req): """Parse a sort direction query param from the request object.""" - sort_dir = req.str_params.get('sort_dir', None) + sort_dir = req.params.get('sort_dir', None) if sort_dir is not None and sort_dir not in SUPPORTED_SORT_DIRS: _keys = ', '.join(SUPPORTED_SORT_DIRS) msg = _("Unsupported sort_dir. Acceptable values: %s") % (_keys,) @@ -245,7 +245,7 @@ class Controller(object): def _get_is_public(self, req): """Parse is_public into something usable.""" - is_public = req.str_params.get('is_public', None) + is_public = req.params.get('is_public', None) if is_public is None: # NOTE(vish): This preserves the default value of showing only @@ -263,7 +263,7 @@ class Controller(object): def _parse_deleted_filter(self, req): """Parse deleted into something usable.""" - deleted = req.str_params.get('deleted') + deleted = req.params.get('deleted') if deleted is None: return None return utils.bool_from_string(deleted)