From 8673a89f2aadb1bf1d1182322c47bb209a1e3265 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Thu, 6 Aug 2009 22:37:04 -0500 Subject: [PATCH] Added api_root to API object to allow usage of library with identica/laconica. Fixed auth checking error that always force authentication. --- tweepy/api.py | 3 ++- tweepy/binder.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) 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: -- 2.25.1