← Back to team overview

lazr-developers team mailing list archive

[Bug 310619] [NEW] Need a way to define arbitrary sections based on a master

 

Public bug reported:

lazr.config has a 'template' feature that at first appears to allow for
defining a category template that can be extended with arbitrary sections in a
config file.   For example:

{{{
from lazr.config import *

with open('schema.cfg', 'w') as fp:
    print >> fp, """\
[woot]
qux: 9

[thing.template]
baz: 1
"""

schema = ConfigSchema('schema.cfg')

with open('config.cfg', 'w') as fp:
    print >> fp, """\
[woot]
qux: 10

[thing.one]

[thing.two]
baz: 2

[thing.three]
baz: 3
"""

config = schema.load('config.cfg')

print 'woot.qux:', config.woot.qux

for section in config.getByCategory('thing'):
    print '%s: %s' % (section.name, section.baz)
}}}

The fact that Curtis, Gary, and I all initially thought this should work is
interesting. :)  It does not however, because category sections are limited to
definition in the schema and cannot be extended in the config (i.e. .push()
does not extend categories).

In discussion with Curtis on irc, we determined that lazr.config should
support something like this, but that .templates is not the right tool for the
job.  Curtis had this suggestion:

"I suggest .master.  In the cases where we have defined service data, we need
a section to define all permitted keys, like template, but is parsed in the
push() method to update the categories."

.master seems right to me.

** Affects: lazr.config
     Importance: Undecided
         Status: New

-- 
Need a way to define arbitrary sections based on a master
https://bugs.launchpad.net/bugs/310619
You received this bug notification because you are a member of LAZR
Developers, which is the registrant for lazr.config.

Status in lazr.config: New

Bug description:
lazr.config has a 'template' feature that at first appears to allow for
defining a category template that can be extended with arbitrary sections in a
config file.   For example:

{{{
from lazr.config import *

with open('schema.cfg', 'w') as fp:
    print >> fp, """\
[woot]
qux: 9

[thing.template]
baz: 1
"""

schema = ConfigSchema('schema.cfg')

with open('config.cfg', 'w') as fp:
    print >> fp, """\
[woot]
qux: 10

[thing.one]

[thing.two]
baz: 2

[thing.three]
baz: 3
"""

config = schema.load('config.cfg')

print 'woot.qux:', config.woot.qux

for section in config.getByCategory('thing'):
    print '%s: %s' % (section.name, section.baz)
}}}

The fact that Curtis, Gary, and I all initially thought this should work is
interesting. :)  It does not however, because category sections are limited to
definition in the schema and cannot be extended in the config (i.e. .push()
does not extend categories).

In discussion with Curtis on irc, we determined that lazr.config should
support something like this, but that .templates is not the right tool for the
job.  Curtis had this suggestion:

"I suggest .master.  In the cases where we have defined service data, we need
a section to define all permitted keys, like template, but is parsed in the
push() method to update the categories."

.master seems right to me.



Follow ups

References