Example #1
0
        def _exists(ret):
            if not ret:
                return defer.fail(FeedDoesNotExist())

            dl = []
            for k, v in config.items():
                dl.append(self.redis.hset('feed.config:%s' % feed_name, k, v))
            return defer.DeferredList(dl)
Example #2
0
 def _publish(ret):
     """
     Called when redis.sadd returns.
     """
     if ret == 1:
         d = self._publish_channel("newfeed", feed_name)
         d.addCallback(_set_config)
         return d
     else:
         return defer.fail(FeedExists())
Example #3
0
        def _exec_check(bulk_result):
            # All defers must be succeed
            assert all([a[0] for a in bulk_result])
            # assert number of commands
            assert len(bulk_result) >= 3

            multi_result = bulk_result[-1][1]
            if multi_result:
                # transaction done :D
                # assert number commands in transaction
                assert len(multi_result) >= 2
                # check if feed_name existed when was deleted
                exists = multi_result[0]
                if not exists:
                    return defer.fail(FeedDoesNotExist())
                return True

            # transaction fail :-(
            # repeat it
            return self.delete_feed(feed_name)
Example #4
0
        def _exists(ret):
            if not ret:
                return defer.fail(FeedDoesNotExist())

            return self.redis.hgetall('feed.config:%s' % feed_name)