From: Ivan Kolodyazhny Date: Mon, 22 Sep 2014 13:30:11 +0000 (+0300) Subject: Use urllib.urlencode instead of dict_to_query_str X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6eeddef0967b3ad5fc1dc20605a428398b820ae6;p=openstack-build%2Fcinder-build.git Use urllib.urlencode instead of dict_to_query_str dict_to_query_str is only used to generate 'next' links and this part of data is not used in a cinderclient now. So it is safe to move forward and generate correct links right now. Change-Id: I1d7a2e0bff3827011a787b70d7c54cd6a0b5de1f --- diff --git a/cinder/api/common.py b/cinder/api/common.py index ace08ec36..95cb39986 100644 --- a/cinder/api/common.py +++ b/cinder/api/common.py @@ -16,6 +16,7 @@ import os import re +import urllib from oslo.config import cfg import six.moves.urllib.parse as urlparse @@ -197,16 +198,6 @@ def remove_version_from_href(href): return urlparse.urlunsplit(parsed_url) -def dict_to_query_str(params): - # TODO(throughnothing): we should just use urllib.urlencode instead of this - # But currently we don't work with urlencoded url's - param_str = "" - for key, val in params.iteritems(): - param_str = param_str + '='.join([str(key), str(val)]) + '&' - - return param_str.rstrip('&') - - class ViewBuilder(object): """Model API responses as dictionaries.""" @@ -227,7 +218,7 @@ class ViewBuilder(object): url = os.path.join(prefix, request.environ["cinder.context"].project_id, collection_name) - return "%s?%s" % (url, dict_to_query_str(params)) + return "%s?%s" % (url, urllib.urlencode(params)) def _get_href_link(self, request, identifier): """Return an href string pointing to this object."""