]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Use urllib.urlencode instead of dict_to_query_str
authorIvan Kolodyazhny <e0ne@e0ne.info>
Mon, 22 Sep 2014 13:30:11 +0000 (16:30 +0300)
committerIvan Kolodyazhny <e0ne@e0ne.info>
Sat, 1 Nov 2014 18:56:44 +0000 (20:56 +0200)
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

cinder/api/common.py

index ace08ec36d526177c3769cc9e355cfecd8324e55..95cb3998677a30848c46793e7aa18fc047a17523 100644 (file)
@@ -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."""