Reputation: 2449
For development it seems you would like to have a localhost value in the config file for the database. However I also want to have a production setup too.
It seems it discusses it here: http://flask.pocoo.org/docs/0.10/config/#configuring-from-files
It recommend this approach:
app = Flask(__name__)
app.config.from_object('config')
app.config.from_envvar('YOURAPPLICATION_SETTINGS')
export YOURAPPLICATION_SETTINGS=/path/to/settings.cfg
My question is, why wouldn't you just point directly to the production file, rather than pointing to the envvar which points to the config location. It seems like an unnecessary step.
app = Flask(__name__)
app.config.from_object('config')
app.config.from_envvar('config_production')
Upvotes: 0
Views: 190
Reputation: 11187
Not sure if that's considered the "preferred" approach (many people have different preferences), but what I would say is beneficial is that you don't have to touch your code on the environment to update its configuration. Eg, if you were on heroku, you could do heroku config:set YOURAPPLICATION_SETTINGS=/path/
. Less risky, easier to handle on a variety of environments.
Upvotes: 1
Reputation: 558
It seems that it will make the maintance of produced application be much easier to sysadmin, who might dont know about Flask even python!
so if you set the path in environmental variables that is a familiar term for all, it will be much easier ;)
Upvotes: 0