Commits

Jesper Nøhr committed 474e1d8

multiple perpretrators

  • Participants
  • Parent commits 85d3492

Comments (0)

Files changed (1)

File src/rewsfeed/models.py

     def newsfeed(self, kls, start=0, end=20):
         for hsh in self.network.zrange(Op.NEWSFEED_KEY+self.key(), start, end):
             yield kls(self.network, **self.network.hgetall(Op.DATA_KEY+hsh))
-        
+
+    def num_newsfeed(self):
+        return self.network.zcard(Op.NEWSFEED_KEY+self.key())
+            
 class Event(DictAbstracted):
     """
     Funky events.
     
     @classmethod
     def add_event(cls, network, who, callback=always, **kwargs):
-        if not isinstance(who, FollowAble):
+        if not isinstance(who, (FollowAble, list, tuple)):
             raise ValueError("A `FollowAble` must've done it. You gave me '%r'" % who)
 
         if not kwargs.has_key('timestamp'):
 
         event = cls(network, **kwargs).save()
             
-        who.did(event, callback)
+        if isinstance(who, (list, tuple)):
+            for perp in who:
+                perp.did(event, callback)
+        elif isinstance(who, FollowAble):
+            who.did(event, callback)