[merge] LazyFactory

John Arbash Meinel john at arbash-meinel.com
Tue Aug 15 19:29:23 BST 2006


Aaron Bentley wrote:
> Adeodato Simó wrote:
>>> I know I want to look into Aaron's optparse branch and move from
>>> EnumOption for --log-format to an option that gets the possible values
>>> from a registry. That should solve the "formats registered by plugins
>>> don't show in help" problem. And ditto for my commit --template option.
> 
> I've already said that I'm working on something similar.  Your solution
> doesn't seem to address everything that mine does.
> 
> Specifically,
>  - it doesn't guarantee ordering
>  - it doesn't provide help text in a uniform way
>  - it ignores per-command defaults
> 
> So in its current state, I wouldn't welcome it.
> 
> Aaron

Registry would not be the exact class for doing option handling.
The important part is that they extend from a common Registry interface.
Just for consistency across bzr.

Right now, we have log formats, merge formats, transports, branch
formats, repository formats, ... All which have slightly different
semantics about how to add a new one.

There will still be some differences, but hopefully as much similarity
can be preserved.

We certainly can have a registry that preserves the order that keys are
registered.

I would like this to be something that you can ultimately use. So what
do you need for things like 'per-command defaults'.

The OptionRegistry would probably be extended so that it used something
more like:

def __init__(self, option_name):
def register(name, help_text, klass):

So when you register a new entry, you are required to pass in the help
text, etc. And the name of the option is supplied when creating the
option list. It would also be possible that individual option lists need
to subclass OptionRegistry, and then we use self.__class__.__name__, but
I think a parameter is better than a subclass.

John
=:->

-------------- 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/20060815/1a1b2750/attachment.pgp 


More information about the bazaar mailing list