[bzr-email:MERGE] cleanup imports

John Arbash Meinel john at arbash-meinel.com
Wed Feb 7 15:52:13 GMT 2007


Robert Collins wrote:
> If you have bzr-email HEAD, and my branch-hooks bundle applied, you can
> remove the
> post_commit = bzrlib.plugins.email.post_commit
> line from your config, as it uses the new hooks facility.
> 
> Also - John, can we do lazy loading rather than the manual import foo in
> the __init__ ?  It seems a bit ugly at the moment.
> 
> -Rob
> 

What do you think about this change? It cleans up the importing to be
lazy, as well as check that the plugin is installed with the expected
name. If it isn't, it errors out quickly, rather than at post-commit time.

Technically if we wanted we could actually use '__name__' to not require
a specific import name, by switching to

this_mod = __import__(__name__, globals(), locals(), ['emailer'])
emailer = getattr(this_mod, 'emailer')

Or we could just switch and do

import emailer

rather than using

import bzrlib.plugins.email.emailer

I'm happy enough with this patch, are you?

John
=:->

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: email_import_cleanup.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20070207/c71cfbc7/attachment.diff 


More information about the bazaar mailing list