[merge] LazyFactory

John Arbash Meinel john at arbash-meinel.com
Wed Aug 9 22:57:40 BST 2006


I wrote a simple helper class, that I would like to start using in other
code for bzr. So I figured I would get it reviewed on its own.

Basically, it is just a factory style class, where you register a module
and a member, associated with a given key. And then later on, when
requested, it will import the module, and return the member.

I think we have quite a few use cases for this sort of ability, and it
is best if we create a real factory class, and build up our lazy work
around it, rather than re-inventing the wheel each time.

I think we could use this for transports. I'm planning on using it along
with 'version_info' so that I can register multiple formatters for
creating info, but I don't actually have to load that code until I need it.

I think we also could ultimately use it as a base class for command
handling. Whenever we get around to splitting up commands into
late-loaded modules. I think it will need to be extended, because we
need the alias information about commands before we can import them this
way. But I think it would be a reasonable base class.

John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lazy-factory.patch
Type: text/x-patch
Size: 7848 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060809/30a3a113/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060809/30a3a113/attachment.pgp 


More information about the bazaar mailing list