Commits

zuroc committed 9bbb70c

f

  • Participants
  • Parent commits 709c12f

Comments (0)

Files changed (4)

File model/feed.py

 import _env
 from config import Model , ModelMc, redis, redis_key
 from time import time
+from follow import follow_user_id_list
 
 FEED_LIMIT = 1042
 

File model/feed_po.py

 #!/usr/bin/env python
 #coding:utf-8
+import _env
+from config import redis
+
 from feed import Feed as _Feed
 from follow import follow_user_id_list
 from po import Po
             if not redis.exists(key):
                 _follow_new(from_id, from_id)
         return _follow_new(from_id, to_id)
-    
+
     def _merge(self, user_id, follow_user_id_list, last_id=None, limit=42):
         id_list = self.merge_by_follow_user_id_list(
             user_id,
             last_id,
             limit
         )
+        return Po.mc_get_list(id_list)
 
     def merge_by_user_id(
         self, user_id, last_id=None, limit=42
         id_list.extend(follow_user_id_list(user_id))
         return self._merge(user_id, id_list, last_id, limit)
 
-if __name__ == "__main__":
-    import sys
-    if sys.getdefaultencoding() == 'ascii':
-        reload(sys)
-        sys.setdefaultencoding('utf-8')
 
+feed_po = Feed('Po')
 
+if __name__ == '__main__':
+    print feed_po.merge_by_user_id(9)
 
 
 
+

File model/follow.py

 import _env
 from config import redis
 
-REDIS_FOLLOW = "Follow:%s"
-REDIS_FOLLOW_LIST = "FollowList:%s"
+REDIS_FOLLOW = 'Follow:%s'
+REDIS_FOLLOW_LIST = 'FollowList:%s'
 
 def follow_new(from_id, to_id):
+    from feed_po import feed_po
+    feed_po.follow_new(from_id, to_id)
     p = redis.pipeline()
+    p.lrem(REDIS_FOLLOW_LIST%from_id, 0, to_id)
     p.lpush(REDIS_FOLLOW_LIST%from_id, to_id)
-    p.sadd(REDIS_FOLLOW%from_id, to_id) 
+    p.sadd(REDIS_FOLLOW%from_id, to_id)
     p.execute()
 
 def follow_rm(from_id, to_id):
     redis.lrem(REDIS_FOLLOW_LIST%from_id, 0, to_id)
-    redis.srem(REDIS_FOLLOW%from_id, to_id) 
+    redis.srem(REDIS_FOLLOW%from_id, to_id)
 
 def follow_get(from_id, to_id):
-    return redis.sismember(REDIS_FOLLOW%from_id, to_id) 
+    return redis.sismember(REDIS_FOLLOW%from_id, to_id)
 
+def follow_user_id_list(from_id):
+    return redis.smembers(REDIS_FOLLOW%from_id)
 
-if __name__ == "__main__":
-    follow_new(9,11)
-    print follow_get(9, 11)
+if __name__ == '__main__':
+    follow_new(9, 11)
+    #print follow_get(9, 11)
+    print follow_user_id_list(9)
 
 
 
     pass
 
 def po_weibo_new(user_id, name):
+    from model.feed_po import feed_po
     po = Po(user_id=user_id, name=name, txt='').save()
     _mc_flush(user_id)
+    feed_po.new(po.id, user_id)
     return po
 
 def po_weibo_rm(id):