Added api_root to API object to allow usage of library with identica/laconica. Fixed...
authorJosh Roesslein <jroesslein@gmail.com>
Fri, 7 Aug 2009 03:37:04 +0000 (22:37 -0500)
committerJosh Roesslein <jroesslein@gmail.com>
Fri, 7 Aug 2009 03:37:04 +0000 (22:37 -0500)
tweepy/api.py
tweepy/binder.py

index 3d8f2a072e78ab61335598c2c07e2628479f2fbc..c72e2e15a065e0eaee1d47981c62d98d524083b8 100644 (file)
@@ -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
index b2faf162b8e583d2c9fa23fa22551a5050b5c090..77529728268e780639bea2af4d588d8553118dd5 100644 (file)
@@ -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: