On Fri, May 18, 2012 at 12:16 PM, Andrew Bogott <abog...@wikimedia.org>wrote:
> On 5/17/12 4:38 PM, Doug Hellmann wrote: > > > <snip> > > > In the wikistatus plugin I notice that you modify the global FLAGS when > wikistatus.py is imported. Is that the right time to do that, or should it > happen during the on-load handler in the plugin class? Or maybe even in the > plugin manager, which could ask the plugin for the new options and then > modify FLAGS itself. It seems like lots of Nova code modifies FLAGS during > import, but having an explicit trigger for that (rather than depending on > import order) seems safer to me. > > I don't feel strongly about this -- I'm just following the example set by > existing Nova code. Can you think of a corner case where loading it at > import time would cause problems? Alternatively, can you think of a corner > case where we would want a flag to be defined during the magic moment > /between/ import time and the load callback? > I don't know enough about how the flags code works or whether the order of flag declarations matters. I based my comments on the fact that I have been burned in the (distant) past by library code that modified global state on import (Zope) so I avoid the pattern and stick with explicit triggers. If the flags module supports modification in an indeterminate order, which the existing convention implies, then what you have should be fine. > > I can't think of a case for either, although I have the vague feeling that > the latter is slightly more possible (if still improbable.) > > > > If the entry point for each plugin is given a unique name (instead of > being called "plugin", as the sharedfs plugin is) we would be able to log > "loading plugin X" as well as provide options to control which plugins are > activated. I don't know if that latter idea is a goal or not. > > If leaving in that option is free, then I'm all for it. I'm still a bit > new to entry points... is the entry-point name a totally arbitrary string? > The names need to work as variable names for ConfigParser. I don't think they can include whitespace or '.' but I'm not sure about other restrictions. Also, is supporting unique names the same thing as /requiring/ unique > names? Would this ultimately result in us needing a governed, hierarchical > namespace? > You cannot have two entry points with the same name in the same setup.py, but you can have duplicate names from different setup.py files. Whether you want to do that depends on how you are using the plugins. In this case, it shouldn't matter if there are duplicates *unless* we provide an option to enable/disable plugins. > > > > - Two different loading pathways -- is that useful or just confusing? >> > > > "One and only one obvious way to do it." > > > OK, I'm convinced. Outside of the common client, are entrypoints already > a hard dependency elsewhere in OpenStack such that we don't lose anything > by requiring them? > >From what I have seen all of the projects use setuptools/distribute for packaging, so using entry points will not add any new dependencies. > > > > >> - Should the plugin base class interpose itself between the plugin and >> python-openstackclient in order to enforce interface versioning? Is that >> even possible? >> > > We could probably figure out a way to do that, but I don't know why you > would want to. What did you have in mind? Which interface are you worried > about versioning, the CLI itself? > > > I'm not sure I do want to, but here's my concern: Right now the common > client's API for extending the commandline is entirely internal to the > common client itself. When I write the sharedfs plugin to make use of that > same API, I'm treating that internal API as external... and I don't like > being the only person in the world doing that. > The command plugin API for the common CLI is intended to be public and will be documented. I thought we were going to put the command implementations in project-specific packages (so that you only got the quantum commands if you installed the python-quantumclient package, for example). Dean convinced me we should just put the core stuff into one package, so we went that route. Extensions can plug directly in. We will document the base classes within the openstackclient library, but extensions can also write directly against the cliff framework classes if they do not need any of the features specific to the unified CLI. Of course, if the expectation is that that common client API will soon > become public/documented/frozen anyway, then there's no problem. > > -Andrew > >
_______________________________________________ Mailing list: https://launchpad.net/~openstack Post to : openstack@lists.launchpad.net Unsubscribe : https://launchpad.net/~openstack More help : https://help.launchpad.net/ListHelp