So I am getting to have a pretty respectable API built, but their is one thing still bugging me. Configuration. I am still sitting here with a settings dictionary in an
app.py file. I tried using a
config.ini file and then a config parser, but that seems like a lot of work just to create a settings dictionary from single key value pairs. I am toying with the idea of just using a
config.py file, and writing a factory function that returns an App. Many different ways to skin this cat. Putting 12-15 environmental variables on my machine is also not really ideal. Especially when you run gunicorn you have to pass those in since the process doesn’t get access to the environment variables on the machine. Essentially I end up with the config just sitting in the app.service if I go that route.
I am also struggling with how to pass through configuration settings down to subpackages of my application. Right now the config file lives outside of a my application package and while the Settings component works for my annotated routes I can’t seem to access settings anywhere else due to model import errors. I am trying to set something like the number of bcrypt rounds in the settings instead of having them hard coded.
How are you guys handling configuration?