Python style question

Lalo Martins lalo at
Tue Jun 7 03:14:34 BST 2005

And so says John A Meinel on 06/06/2005 10:53 PM...
> The problem is that really you want a branch hierarchy. You can argue
> that you want a standard Branch object and a BranchStorage hierarchy. It
> doesn't really matter, but to me, that is just one more layer of
> indirection that you don't really need.

Actually, I think I like this idea.  Seems cleaner to me.  You don't
really need separate Branch classes.

Also I would put the check for "is this the right type" in the constructor.

class DeclineStorageArgs(Exception):

class Branch(object):
    # docstring and stuff...
    storage_registry = [LocalStorage]

    def __init__(self, *args, **kw):
        # ...
        for storage_class in self.storage_registry:
       = storage_class(*args, **kw)
            except DeclineStorageArgs:
        # ...

    def register_storage(cls, storage_class, pos=0):
        if pos is None:
            cls.storage_registry.insert(pos, storage_class)

                                               Lalo Martins
      So many of our dreams at first seem impossible,
       then they seem improbable, and then, when we
       summon the will, they soon become inevitable.
--                  mailto:lalo at
GNU: never give up freedom       

More information about the bazaar mailing list