Added follow/unfollow shortcuts to User model. Fixed issue with User.following being...
authorJosh Roesslein <jroesslein@gmail.com>
Thu, 13 Aug 2009 18:34:32 +0000 (13:34 -0500)
committerJosh Roesslein <jroesslein@gmail.com>
Thu, 13 Aug 2009 18:34:32 +0000 (13:34 -0500)
CHANGES
ROADMAP
tweepy/models.py
tweepy/parsers.py

diff --git a/CHANGES b/CHANGES
index d826004cdbcb0b7ed0ab716b1479eaf2ee42db39..f3fe1c7bcec351424f83fe03215e4f4b122ef25c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,5 +2,11 @@ All changes made to the library that might affect applications
 during upgrade will be listed here.
 
 1.0 -> 1.0.1
-------------
-Status.user --> Status.author
+============
++ Status.user --> Status.author
++ User:
+    + follow()
+    + unfollow()
++ Fixes
+    + User.following is now set to False instead of None
+      when user is not followed.
diff --git a/ROADMAP b/ROADMAP
index 79e6f41d334c3a3959753047a0fe23658d303621..e2b61d0695fc7d9fbb0cde0ee5aad676cc293cdb 100644 (file)
--- a/ROADMAP
+++ b/ROADMAP
@@ -9,4 +9,5 @@ The plan of attack for the next version of Tweepy.
 + rate limit governor
 + prepare for social graph changes mentioned on mailinglist
 + finish search api
++ autodetect authenticated user's ID
 
index eb5ec14afacaa6893f970b851563a68f7194c5f2..329a2361273228066f2de2c1a09960be95440b5a 100644 (file)
@@ -68,6 +68,13 @@ class User(Model):
   def followers(self, **kargs):
     return self._api.followers(id=self.id, **kargs)
 
+  def follow(self):
+    self._api.create_friendship(user_id=self.id)
+    self.following = True
+  def unfollow(self):
+    self._api.destroy_friendship(user_id=self.id)
+    self.following = False
+
 class DirectMessage(Model):
 
   def destroy(self):
index 0f3f2f9ee4e2e04597085f3c48dde8af3c94677a..bbde005f305f6185c061a8a229a9afd50cd4fba4 100644 (file)
@@ -52,6 +52,12 @@ def _parse_user(obj, api):
       setattr(user, k, _parse_datetime(v))
     elif k == 'status':
       setattr(user, k, _parse_status(v, api))
+    elif k == 'following':
+      # twitter sets this to null if it is false
+      if v is True:
+        setattr(user, k, True)
+      else:
+        setattr(user, k, False)
     else:
       setattr(user, k, v)
   return user