Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-08 Thread Matthew Booth
On 08/08/14 11:04, Matthew Booth wrote: > On 07/08/14 18:54, Kevin L. Mitchell wrote: >> On Thu, 2014-08-07 at 17:46 +0100, Matthew Booth wrote: In any case, the operative point is that CONF. must >>> always be evaluated inside run-time code, never at module load time. >>> >>> ...unless y

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-08 Thread Matthew Booth
On 07/08/14 19:02, Kevin L. Mitchell wrote: > On Thu, 2014-08-07 at 17:41 +0100, Matthew Booth wrote: >> ... or arg is an object which defines __nonzero__(), or defines >> __getattr__() and then explodes because of the unexpected lookup of a >> __nonzero__ attribute. Or it's False (no quotes when p

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-08 Thread Matthew Booth
On 07/08/14 18:54, Kevin L. Mitchell wrote: > On Thu, 2014-08-07 at 17:46 +0100, Matthew Booth wrote: >>> In any case, the operative point is that CONF. must >> always be >>> evaluated inside run-time code, never at module load time. >> >> ...unless you call register_opts() safely, which is what I'

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Brant Knudson
On Thu, Aug 7, 2014 at 12:54 PM, Kevin L. Mitchell < kevin.mitch...@rackspace.com> wrote: > On Thu, 2014-08-07 at 17:46 +0100, Matthew Booth wrote: > > > In any case, the operative point is that CONF. must > > always be > > > evaluated inside run-time code, never at module load time. > > > > ...un

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Doug Hellmann
On Aug 7, 2014, at 12:39 PM, Kevin L. Mitchell wrote: > On Thu, 2014-08-07 at 17:27 +0100, Matthew Booth wrote: >> On 07/08/14 16:27, Kevin L. Mitchell wrote: >>> On Thu, 2014-08-07 at 12:15 +0100, Matthew Booth wrote: A (the?) solution is to register_opts() in foo before importing any >>>

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Kevin L. Mitchell
On Thu, 2014-08-07 at 17:41 +0100, Matthew Booth wrote: > ... or arg is an object which defines __nonzero__(), or defines > __getattr__() and then explodes because of the unexpected lookup of a > __nonzero__ attribute. Or it's False (no quotes when printed by the > debugger), but has a unicode type

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Kevin L. Mitchell
On Thu, 2014-08-07 at 17:46 +0100, Matthew Booth wrote: > > In any case, the operative point is that CONF. must > always be > > evaluated inside run-time code, never at module load time. > > ...unless you call register_opts() safely, which is what I'm > proposing. No, calling register_opts() at a

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Kevin L. Mitchell
On Thu, 2014-08-07 at 17:44 +0100, Matthew Booth wrote: > These are tricky, case-by-case workarounds to a general problem which > can be solved by simply calling register_opts() in a place where it's > guaranteed to be safe. No, THE CODE IS WRONG. It is evaluating a configuration value at _modul

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Matthew Booth
On 07/08/14 17:39, Kevin L. Mitchell wrote: > On Thu, 2014-08-07 at 17:27 +0100, Matthew Booth wrote: >> On 07/08/14 16:27, Kevin L. Mitchell wrote: >>> On Thu, 2014-08-07 at 12:15 +0100, Matthew Booth wrote: A (the?) solution is to register_opts() in foo before importing any modules whic

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Matthew Booth
On 07/08/14 17:34, Dan Smith wrote: >> That's different behaviour, because you can no longer pass arg=None. The >> fix isn't to change the behaviour of the code. > > So use a sentinel... That would also be a change to the behaviour of the code, because you can no longer pass in the sentinel. The

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Matthew Booth
On 07/08/14 17:11, Kevin L. Mitchell wrote: > On Thu, 2014-08-07 at 10:55 -0500, Matt Riedemann wrote: >> >> On 8/7/2014 10:27 AM, Kevin L. Mitchell wrote: >>> On Thu, 2014-08-07 at 12:15 +0100, Matthew Booth wrote: A (the?) solution is to register_opts() in foo before importing any modul

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Kevin L. Mitchell
On Thu, 2014-08-07 at 17:27 +0100, Matthew Booth wrote: > On 07/08/14 16:27, Kevin L. Mitchell wrote: > > On Thu, 2014-08-07 at 12:15 +0100, Matthew Booth wrote: > >> A (the?) solution is to register_opts() in foo before importing any > >> modules which might also use oslo.config. > > > > Actually

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Dan Smith
> That's different behaviour, because you can no longer pass arg=None. The > fix isn't to change the behaviour of the code. So use a sentinel... --Dan signature.asc Description: OpenPGP digital signature ___ OpenStack-dev mailing list OpenStack-dev@l

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Matthew Booth
On 07/08/14 16:27, Kevin L. Mitchell wrote: > On Thu, 2014-08-07 at 12:15 +0100, Matthew Booth wrote: >> A (the?) solution is to register_opts() in foo before importing any >> modules which might also use oslo.config. > > Actually, I disagree. The real problem here is the definition of > bar_func

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Kevin L. Mitchell
On Thu, 2014-08-07 at 10:55 -0500, Matt Riedemann wrote: > > On 8/7/2014 10:27 AM, Kevin L. Mitchell wrote: > > On Thu, 2014-08-07 at 12:15 +0100, Matthew Booth wrote: > >> A (the?) solution is to register_opts() in foo before importing any > >> modules which might also use oslo.config. > > > > Ac

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Matt Riedemann
On 8/7/2014 10:27 AM, Kevin L. Mitchell wrote: On Thu, 2014-08-07 at 12:15 +0100, Matthew Booth wrote: A (the?) solution is to register_opts() in foo before importing any modules which might also use oslo.config. Actually, I disagree. The real problem here is the definition of bar_func().

Re: [openstack-dev] [nova][oslo] oslo.config and import chains

2014-08-07 Thread Kevin L. Mitchell
On Thu, 2014-08-07 at 12:15 +0100, Matthew Booth wrote: > A (the?) solution is to register_opts() in foo before importing any > modules which might also use oslo.config. Actually, I disagree. The real problem here is the definition of bar_func(). The default value of the parameter "arg" will lik

Re: [openstack-dev] [nova][oslo] oslo.config and import chains (a proposal to update the style guidelines for imports)

2014-08-07 Thread Matthew Booth
On 07/08/14 12:15, Matthew Booth wrote: > I'm sure this is well known, but I recently encountered this problem for > the second time. > > --- > foo: > import oslo.config as cfg > > import bar > > CONF = cfg.CONF > CONF.register_opts('foo_opt') > > --- > bar: > import oslo.config as cfg > > CON