def __init__(self, user_id, **kwargs):
        '''
        User id (the user for which we want to read/write notifications)
        '''
        AggregatedFeed.__init__(self, user_id, **kwargs)

        # location to which we denormalize the count
        self.format_dict = dict(user_id=user_id)
        self.count_key = self.count_format % self.format_dict
        # set the pubsub key if we're using it
        self.pubsub_key = user_id
        self.lock_key = self.lock_format % self.format_dict
        from stream_framework.storage.redis.connection import get_redis_connection
        self.redis = get_redis_connection()
Exemple #2
0
    def __init__(self, user_id, **kwargs):
        '''
        User id (the user for which we want to read/write notifications)
        '''
        AggregatedFeed.__init__(self, user_id, **kwargs)

        # location to which we denormalize the count
        self.format_dict = dict(user_id=user_id)
        self.count_key = self.count_format % self.format_dict
        # set the pubsub key if we're using it
        self.pubsub_key = user_id
        self.lock_key = self.lock_format % self.format_dict
        from stream_framework.storage.redis.connection import get_redis_connection
        self.redis = get_redis_connection()
 def add_many(self, activities, **kwargs):
     '''
     Similar to the AggregatedActivity.add_many
     The only difference is that it denormalizes a count of unseen activities
     '''
     with self.redis.lock(self.lock_key, timeout=2):
         current_activities = AggregatedFeed.add_many(
             self, activities, **kwargs)
         # denormalize the count
         self.denormalize_count()
         # return the current state of the notification feed
         return current_activities
Exemple #4
0
 def add_many(self, activities, **kwargs):
     '''
     Similar to the AggregatedActivity.add_many
     The only difference is that it denormalizes a count of unseen activities
     '''
     with self.redis.lock(self.lock_key, timeout=2):
         current_activities = AggregatedFeed.add_many(
             self, activities, **kwargs)
         # denormalize the count
         self.denormalize_count()
         # return the current state of the notification feed
         return current_activities