Commits

Anonymous committed 7edfae3

fix bug spotted by david`bgk on irc. You could now pass int values as
params (or any other type).

  • Participants
  • Parent commits 73a5a1d
  • Tags v1.1.4

Comments (0)

Files changed (9)

docs/_build/doctrees/environment.pickle

Binary file modified.

docs/_build/doctrees/index.doctree

Binary file modified.

docs/_build/doctrees/installation.doctree

Binary file modified.

docs/_build/doctrees/resource.doctree

Binary file modified.

docs/_build/doctrees/whatsnew.doctree

Binary file modified.

restclient/rest.py

             elif v is not None:
                 params.append((k,v))
         if params:
-            retval.extend(['?', url_encode(params, self.charset, self.encode_keys)])
+            retval.extend(['?', url_encode(dict(params), self.charset, self.encode_keys)])
 
         return ''.join(retval)
 
 
 def url_encode(obj, charset="utf8", encode_keys=False):
     if isinstance(obj, dict):
+        items = []
         for k, v in obj.iteritems():
             if not isinstance(v, (tuple, list)):
                 v = [v]
         items = obj or ()
 
     tmp = []
-    for key, value in items:
+    for key, values in items:
         if encode_keys and isinstance(key, unicode):
             key = key.encode(charset)
         else:
             key = str(key)
+
+        for value in values:
+            if value is None:
+                continue
+            elif isinstance(value, unicode):
+                value = value.encode(charset)
+            else:
+                value = str(value)
         tmp.append('%s=%s' % (urllib.quote(key),
             urllib.quote_plus(value)))
 

restclient/transport.py

 
         if put:
             headers.setdefault('Expect', '100-continue')
-        
+
         c = pycurl.Curl()
         try:
             # set curl options

tests/_server_test.py

                 self._respond(200, extra_headers, "ok")
             else:
                 self.error_Response()
+        elif path == "/qint":
+            test = self.query.get("test", False)
+            if test and test == "1":
+                extra_headers = [('Content-type', 'text/plain')]
+                self._respond(200, extra_headers, "ok")
+            else:
+                self.error_Response()
         elif path == "/auth":
             extra_headers = [('Content-type', 'text/plain')]
 

tests/resource_test.py

         result = self.res.get('/query', test="testing")
         self.assert_(result.http_code == 200)
 
+    def testGetWithIntParam(self):
+        result = self.res.get('/qint', test=1)
+        self.assert_(result.http_code == 200)
+
 
     def testSimplePost(self):
         result = self.res.post(payload="test")
         result = self.res.put('/empty',headers={'Content-Type': 'application/json'})
         self.assert_(result.http_code == 200 )
 
-    def testPuWithQuery(self):
+    def testPutWithQuery(self):
         result = self.res.put('/query', test="testing")
         self.assert_(result.http_code == 200)