From: Josh Roesslein Date: Fri, 7 Aug 2009 03:08:25 +0000 (-0500) Subject: Added support for non-keyword parameters. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7eac1d3e2c3b139cbc04061876d36a497c66d3e1;p=tweepy.git Added support for non-keyword parameters. --- diff --git a/tweepy/binder.py b/tweepy/binder.py index fe66c7b..b2faf16 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -16,9 +16,18 @@ def bind_api(path, parser, allowed_param=None, method='GET', require_auth=False, if not api.auth_handler: raise TweepError('Authentication required!') - # Filter out unallowed parameters + # build parameter dict if allowed_param: - parameters = dict((k,v) for k,v in kargs.items() if k in allowed_param) + parameters = {} + for idx, arg in enumerate(args): + try: + parameters[allowed_param[idx]] = arg + except IndexError: + raise TweepError('Too many parameters supplied!') + for k, arg in kargs.items(): + if k in parameters: + raise TweepError('Multiple values for parameter %s supplied!' % k) + parameters[k] = arg else: parameters = None @@ -54,9 +63,9 @@ def bind_api(path, parser, allowed_param=None, method='GET', require_auth=False, # Open connection if api.secure: - conn = httplib.HTTPSConnection(_host) + conn = httplib.HTTPSConnection(_host, timeout=10) else: - conn = httplib.HTTPConnection(_host) + conn = httplib.HTTPConnection(_host, timeout=10) # Build request conn.request(method, url, headers=headers)