from base import BaseBackend
from redis import RedisBackend

class MultipleBackend(BaseBackend):
    classes = []

    def __init__(self, *args):
        if not self.classes:
            self.classes = [RedisBackend]

        self.backends = [klass(*args) for klass in self.classes]
        BaseBackend.__init__(self, *args)

    @classmethod
    def count(cls, resq):
        first = MultipleBackend.classes[0]
        return first.count(resq)

    @classmethod
    def all(cls, resq, start=0, count=1):
        first = MultipleBackend.classes[0]
        return first.all(resq, start, count)

    @classmethod
    def clear(cls, resq):
        first = MultipleBackend.classes[0]
        return first.clear(resq)

    def save(self, resq=None):
        map(lambda x: x.save(resq), self.backends)

@@ -90,16 +90,632 @@
 ckend):%0A
+    %22%22%22Extends %60%60BaseBackend%60%60 to provide support for delegating calls to multiple%0A    backends. Queries are delegated to the first backend in the list. Defaults to%0A    only the RedisBackend.%0A%0A    To use:%0A%0A    from pyres import failure%0A%0A    from pyres.failure.base import BaseBackend%0A    from pyres.failure.multiple import MultipleBackend%0A    from pyres.failure.redis import RedisBackend%0A%0A    class CustomBackend(BaseBackend):%0A        def save(self, resq):%0A            print('Custom backend')%0A%0A            failure.backend = MultipleBackend%0A            failure.backend.classes = %5BRedisBackend, CustomBackend%5D%0A    %22%22%22%0A
     clas

Add some doc strings.