OpenAstronomy / baldrick

I have a cunning plan!
https://baldrick.readthedocs.io
MIT License
14 stars 8 forks source link

Formally register and validate configuration items #10

Open astrofrog opened 6 years ago

astrofrog commented 6 years ago

I think each blueprint and plugin should have a way of formally registering configuration items with the app, for instance doing something like:

from flask import current_app
current_app.some_setting = ConfigItem(...)

when the module is loaded. This would allow:

@Cadair - what do you think?

Cadair commented 6 years ago

Sounds like a good plan!

I think we could probably make this a little simpler by restricting the format of the config a little. I.e. each plugin gets it's own key in the top level config dict, with a dict underneath. I also think we should tie this to the app in the minimalist way possible. I.e.

app.config_manager = ConfigManager()

then things register their configs with the manager, and we just use the app as a way to get the reference to the manager.

I wonder if there is a toml schema thing somewhere? If not we could use https://github.com/alecthomas/voluptuous as a way of doing general dict schemas.

astrofrog commented 6 years ago

We now have a Config object so it should be possible to add validation.