Passing params through functions now work, bug fix version bump

For example:
Twython.getHomeTimeline(include_rts=True) was failing. Really sorry
about this. It is now fixed.
This commit is contained in:
Michael Helmick 2012-03-23 15:46:19 -04:00
parent 861c05718d
commit 23e529e167
2 changed files with 6 additions and 5 deletions

View file

@ -4,7 +4,7 @@ from setuptools import setup
from setuptools import find_packages from setuptools import find_packages
__author__ = 'Ryan McGrath <ryan@venodesigns.net>' __author__ = 'Ryan McGrath <ryan@venodesigns.net>'
__version__ = '1.5.1' __version__ = '1.5.2'
setup( setup(
# Basic package information. # Basic package information.

View file

@ -9,7 +9,7 @@
""" """
__author__ = "Ryan McGrath <ryan@venodesigns.net>" __author__ = "Ryan McGrath <ryan@venodesigns.net>"
__version__ = "1.5.1" __version__ = "1.5.2"
import urllib import urllib
import re import re
@ -210,7 +210,7 @@ class Twython(object):
def _constructFunc(self, api_call, **kwargs): def _constructFunc(self, api_call, **kwargs):
# Go through and replace any mustaches that are in our API url. # Go through and replace any mustaches that are in our API url.
fn = api_table[api_call] fn = api_table[api_call]
base = re.sub( url = re.sub(
'\{\{(?P<m>[a-zA-Z_]+)\}\}', '\{\{(?P<m>[a-zA-Z_]+)\}\}',
# The '1' here catches the API version. Slightly hilarious. # The '1' here catches the API version. Slightly hilarious.
lambda m: "%s" % kwargs.get(m.group(1), '1'), lambda m: "%s" % kwargs.get(m.group(1), '1'),
@ -221,13 +221,14 @@ class Twython(object):
if not method in ('get', 'post', 'delete'): if not method in ('get', 'post', 'delete'):
raise TwythonError('Method must be of GET, POST or DELETE') raise TwythonError('Method must be of GET, POST or DELETE')
myargs = {}
if method == 'get': if method == 'get':
myargs = ['%s=%s' % (key, value) for (key, value) in kwargs.iteritems()] url = '%s?%s' % (url, urllib.urlencode(kwargs))
else: else:
myargs = kwargs myargs = kwargs
func = getattr(self.client, method) func = getattr(self.client, method)
response = func(base, data=myargs) response = func(url, data=myargs)
return simplejson.loads(response.content.decode('utf-8')) return simplejson.loads(response.content.decode('utf-8'))