API methods lists(), lists_memberships(), and lists_subscriptions now accept 'user...
authorBas Westerbaan <bas@fsfe.org>
Thu, 17 Dec 2009 06:17:40 +0000 (00:17 -0600)
committerJoshua <jroesslein@gmail.com>
Thu, 17 Dec 2009 06:17:40 +0000 (00:17 -0600)
Added helpers to User model for lists.

Merged from bwesterb/tweepy @ f26e000ba04b57761578831792d7a7a1adfc8e41

Signed-off-by: Joshua <jroesslein@gmail.com>
CHANGELOG
tweepy/api.py
tweepy/models.py

index d2c5ca21c1c4aeb7351cd045b59f9a6eeaf2bff1..c0dcf8cc9326bc03aa854c1ca665c6e202b32690 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,11 @@ during upgrade will be listed here.
 ===========================
 + Models
     - Added some new helper methods to List model
+    - User model
+        - Added lists_memberships, lists_subscriptions, and lists helpers
++ API
+    - lists(), lists_memberships(), and lists_subscriptions() now
+        take an "user" parameter for specifying which user to query.
 
 1.3 -> 1.4 [current]
 ===========================
index cb2f871c11f8b8e146e15b8988b47788ac1dcbe3..36304e60fac0868cfd002cd0e9808e16a91928fd 100644 (file)
@@ -482,32 +482,26 @@ class API(object):
             require_auth = True
         )(self, *args, **kargs)
 
-    def lists(self, *args, **kargs):
-        return bind_api(
-            path = '/%s/lists.json' % self.auth.get_username(),
-            parser = parse_lists,
-            allowed_param = ['cursor'],
-            require_auth = True
-        )(self, *args, **kargs)
-    lists.pagination_mode = 'cursor'
+    lists = bind_api(
+        path = '/{user}/lists.json',
+        parser = parse_lists,
+        allowed_param = ['user', 'cursor'],
+        require_auth = True
+    )
 
-    def lists_memberships(self, *args, **kargs):
-        return bind_api(
-            path = '/%s/lists/memberships.json' % self.auth.get_username(),
-            parser = parse_lists,
-            allowed_param = ['cursor'],
-            require_auth = True
-        )(self, *args, **kargs)
-    lists_memberships.pagination_mode = 'cursor'
+    lists_memberships = bind_api(
+        path = '/{user}/lists/memberships.json',
+        parser = parse_lists,
+        allowed_param = ['user', 'cursor'],
+        require_auth = True
+    )
 
-    def lists_subscriptions(self, *args, **kargs):
-        return bind_api(
-            path = '/%s/lists/subscriptions.json' % self.auth.get_username(),
-            parser = parse_lists,
-            allowed_param = ['cursor'],
-            require_auth = True
-        )(self, *args, **kargs)
-    lists_subscriptions.pagination_mode = 'cursor'
+    lists_subscriptions = bind_api(
+        path = '/{user}/lists/subscriptions.json',
+        parser = parse_lists,
+        allowed_param = ['user', 'cursor'],
+        require_auth = True
+    )
 
     list_timeline = bind_api(
         path = '/{owner}/lists/{slug}/statuses.json',
index a8b9e43b288585f8ce50f8be45afb2e09d5e4b26..259b4afd15d24268f4a4520c20d6539359743b95 100644 (file)
@@ -52,6 +52,15 @@ class User(Model):
         self._api.destroy_friendship(user_id=self.id)
         self.following = False
 
+    def lists_memberships(self):
+        return self._api.lists_memberships(user=self.screen_name)
+
+    def lists_subscriptions(self):
+           return self._api.lists_subscriptions(user=self.screen_name)
+
+    def lists(self):
+           return self._api.lists(user=self.screen_name)
+
 
 class DirectMessage(Model):