[MERGE] allow 'import bzrlib.plugins.NAME'
John Arbash Meinel
john at arbash-meinel.com
Fri Feb 2 19:43:33 GMT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robert Collins wrote:
> This should be non-contentious: it just allows 'import
> bzrlib.plugins.NAME' at any point after import bzrlib is performed.
>
> This allows plugin X to depend on plugin Y, if Y has a predictable
> name :).
>
> No attempt is made to enforce naming policy or consistency.
>
> There are two minor related changes.
>
> One is that the zip entries on the path are now correctly scanned in
> path order, rather than after all directories.
>
> Secondly, plugins with names that are not legal python identifiers will
> no longer load - and I consider this rather positive ;).
Well, we should at least give a warning about it. Because otherwise
people will install, and not understand why it won't load.
Especially since all Launchpad project names cannot contain underscore,
so we have to default to using '-'. (Which is weird because I can use
'bzr register-branch' to register a branch with an underscore, and
everything seems to work just fine. But if I try to set any other
details like Status, I have to rename it first)
It looks like you will be giving a warning, but I'm wondering if it will
be clear. If it is, then good enough.
>
> Rob
>
...
> + for name in plugin_names:
> + try:
> + exec "import bzrlib.plugins.%s" % name
> + except KeyboardInterrupt:
> + raise
> + except Exception, e:
> + ## import pdb; pdb.set_trace()
> + warning('Unable to load plugin %r from %r' % (name, d))
> + log_exception_quietly()
Wouldn't __import__('bzrlib.plugins.%s' % name) be better? You don't
really want 'bzrlib.plugins.foo' in the current namespace anyway.
And I just tested, and it does put the module into sys.modules[], and it
should also attach it to bzrlib.plugins.* properly.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFw5RlJdeBCYSNAAMRAgBYAJ0a6mWoFGs+wBEYAFINiRzDf8E3yQCdGqkM
L4w+MDsN7HWaiKERVsEiQZc=
=Aj74
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list