[Python-ideas] Application start up hooks
Thomas Güttler
guettli at thomas-guettler.de
Sun May 18 09:34:52 CEST 2014
This is the successor to the thread "logging.config.defaultConfig()".
Thank you for your replies to the first post. I thought agin about my needs: setting up logging.
The more abstract description is "setting up an application". And again, that's something
that should not be done by Python itself.
But there could be standard hooks to build a bridge between developer and operator:
- developer: develops libraries, command lines apps, web apps, ...
- app user: responsible for configuring the app.
Up to to now every application has its own way to set up the application, and
this diversity is good.
All environments are different, but this pattern is common for most applications:
1. use default config provided by the app. These defaults are from the developer of the app.
2. use default config provided by the app user. This can overwrite previous config
3. use explicit config (for example command line arguments) provided by the app user. This can overwrite previous config
I looked at Cement. It provides the above steps, but it provides a lot of other things, too. This
makes it a too heavy weight dependency for many small applications.
I like argparse for command line tools. But it misses loading defaults before parsing the command line
args.
Many post of my first thread said something like "this is not the job of python, handle this in our application yourself".
Now I think you are right.
If there is a good reusable module for loading configs (setting up logging is one part of this) it can live outside
the standard library. And if it is really good, it can get into the standard library in the future.
I know that it is off topic on this list. But it might be useful for other people, too:
Does anyone know a light weight module for loading configuration settings?
Thomas
--
Thomas Güttler
http://thomas-guettler.de/
More information about the Python-ideas
mailing list