[merge] LazyFactory

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


Aaron Bentley wrote:
> John Arbash Meinel wrote:
>>> Aaron Bentley wrote:
>>> 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.
> 
> I'm not sure such consistency will work out well.
> 
>>> 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.
> 
> Yeah, and all but transports need to be exposed as EnumOptions.  So I'm
> inclined towards One Registry Class To Rule Them All.

Sure. I'll also be introducing version-info formats, and I would like to
have Lazy Imported command definitions, etc.

> 
>>> 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'.
> 
> Perhaps that is actually best handled before we hit the Registry.  I was
> thinking I needed to be able to get None or KeyError, but I had it
> backwards.
> 
>>> The OptionRegistry would probably be extended so that it used something
>>> more like:
>>>
>>> def __init__(self, option_name):
>>> def register(name, help_text, klass):
> 
> I was thinking a factory function is all I need.  Is there are reason
> for them to be classes?

Nothing specific. It was more of a 'and the thing you really want'.

> 
>>> 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.
> 
> Yes, I'd prefer to always require a switch name.  It seems better to
> separate the UI representation from the core functionality, at least a
> little bit.
> 
> Aaron

Are you thinking a separate Registry object for each list of formats, or
a single one?

John
=:->

PS> A small thing, but technically transports should also be a
OptionEnum, because it is used by 'cmd_selftest'. You can technically
run the selftest with a custom transport as the default.

-------------- 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/d06e8a68/attachment.pgp 


More information about the bazaar mailing list