[MERGE] Support for lazy registation of commands

Robert Collins robertc at robertcollins.net
Sun Aug 24 10:02:44 BST 2008


On Sun, 2008-08-24 at 11:50 +0300, Alexander Belchenko wrote:
> +class LazyCommandProxy(object):
> +
> +    def __init__(self, module, name, aliases):
> +        self._module = module
> +        self._name = name
> +        self.aliases = aliases
> +        self.__name__ = name
> +
> +    def __call__(self, *args, **kwargs):
> +        cmd_module = __import__(self._module, globals(), locals(), [True])
> +        cmd_class = getattr(cmd_module, self._name)
> +        return cmd_class(*args, **kwargs)
> 
> 
> Why for you pass [True] as last argument to __import__? IMO, you don't need
> to pass there anything. According to Python documentation 4th argument
> lists the names that should be imported from module. So importing name
> 'True' is useless IIUC.
> 
> bb:tweak

Also, we have lazy registries already, we shouldn't be writing any code
that calls __import__ :)

bb:resubmit

-Rob
-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080824/ceb4c70f/attachment-0001.pgp 


More information about the bazaar mailing list