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.attribute must
always be
evaluated inside run-time code, never at module load time.
...unless you call register_opts() safely, which is what I'm
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 printed
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.attribute must
always be
evaluated inside run-time code, never at module load time.
...unless you call
On Aug 7, 2014, at 12:39 PM, Kevin L. Mitchell kevin.mitch...@rackspace.com
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
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.attribute must
always be
evaluated inside run-time code, never at module load time.
...unless
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
CONF = cfg.CONF
def bar_func(arg=CONF.foo_opt):
pass
---
importing foo
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
CONF = cfg.CONF
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 likely
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().
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.
Actually, I
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().
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
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, I
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
modules which might
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.
These
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 which might also
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
_module
On Thu, 2014-08-07 at 17:46 +0100, Matthew Booth wrote:
In any case, the operative point is that CONF.attribute 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
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
19 matches
Mail list logo