From: Josh Roesslein Date: Fri, 7 Aug 2009 03:37:04 +0000 (-0500) Subject: Added api_root to API object to allow usage of library with identica/laconica. Fixed... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8673a89f2aadb1bf1d1182322c47bb209a1e3265;p=tweepy.git Added api_root to API object to allow usage of library with identica/laconica. Fixed auth checking error that always force authentication. --- diff --git a/tweepy/api.py b/tweepy/api.py index 3d8f2a0..c72e2e1 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -11,12 +11,13 @@ from error import TweepError class API(object): def __init__(self, auth_handler=None, username=None, host='twitter.com', cache=None, - secure=False, classes={'user': User, 'status': Status, + secure=False, api_root='', classes={'user': User, 'status': Status, 'direct_message': DirectMessage, 'friendship': Friendship, 'saved_search': SavedSearch, 'search_result': SearchResult}): self.auth_handler = auth_handler self.username = username self.host = host + self.api_root = api_root self.cache = cache self.secure = secure self.classes = classes diff --git a/tweepy/binder.py b/tweepy/binder.py index b2faf16..7752972 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -13,7 +13,7 @@ def bind_api(path, parser, allowed_param=None, method='GET', require_auth=False, def _call(api, *args, **kargs): # If require auth, throw exception if credentials not provided - if not api.auth_handler: + if require_auth and not api.auth_handler: raise TweepError('Authentication required!') # build parameter dict @@ -38,9 +38,9 @@ def bind_api(path, parser, allowed_param=None, method='GET', require_auth=False, # Build url with parameters if parameters: - url = '%s?%s' % (path, urllib.urlencode(parameters)) + url = '%s?%s' % (api.api_root + path, urllib.urlencode(parameters)) else: - url = path + url = api.api_root + path # get scheme and host if api.secure: