Parameters now can be of any type.
The patch by Eugene (9133d0f10e) is nice, because you don't have to
manually encode() the parameters yourself. But it sucks a little,
because all your parameter values must be unicodes now.
Proposed patch encodes unicodes to utf-8 and allows the olde strs and
longs (I love to use longs in 'id' fields somewhy).
This commit is contained in:
parent
9f8c04b0f2
commit
4e690f5568
1 changed files with 7 additions and 1 deletions
|
|
@ -176,7 +176,7 @@ class Twython(object):
|
|||
|
||||
# Then open and load that shiiit, yo. TODO: check HTTP method and junk, handle errors/authentication
|
||||
if fn['method'] == 'POST':
|
||||
resp, content = self.client.request(base, fn['method'], urllib.urlencode(dict([k, v.encode('utf-8')] for k, v in kwargs.items())), headers = self.headers)
|
||||
resp, content = self.client.request(base, fn['method'], urllib.urlencode(dict([k, Twython.encode(v)] for k, v in kwargs.items())), headers = self.headers)
|
||||
else:
|
||||
url = base + "?" + "&".join(["%s=%s" %(key, value) for (key, value) in kwargs.iteritems()])
|
||||
resp, content = self.client.request(url, fn['method'], headers = self.headers)
|
||||
|
|
@ -463,3 +463,9 @@ class Twython(object):
|
|||
except:
|
||||
pass
|
||||
return text
|
||||
|
||||
@staticmethod
|
||||
def encode(text):
|
||||
if isinstance(text, (str,unicode)):
|
||||
return Twython.unicode2utf8(text)
|
||||
return str(text)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue