Is there any way to access options in a shorter format?

Asked by Stuart Metcalfe

For example, I've created my schema and got my config object as described in the getting started docs, but I have to do this to get my configuration:

config.values('__main__')['optionname']
config.values('sectionname')['optionname']

Is there any way to do something slightly shorter like this?

config.optionname <- note: no need to specify __main__
config.sectionname.optionname

Question information

Language:
English Edit question
Status:
Answered
For:
configglue Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Ricardo Kirkner (ricardokirkner) said :
#2

With the code currently in trunk there is. The configglue helper function

>>> class MySchema(Schema):
... project = StringConfigOption(default='my-project')

>>> glue = configglue(MySchema, ['config.ini'])

returns an object which has a 'options' attribute you can use exactly as proposed.

>>> glue.options.project
'my-project'

Can you help with this problem?

Provide an answer of your own, or ask Stuart Metcalfe for more information if necessary.

To post a message you must log in.