Setting fallback values for local development
yuvadm opened this issue · 1 comments
yuvadm commented
What would be the proper way to set fallback values in case DATABASE_URL
(for example) is not set on a development environment?
Right now the proper way seems to be:
from os import environ
heroku = Heroku(app)
if 'DATABASE_URL' not in environ:
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
Is there any way to get this fallback behavior from flask-heroku?
lyndsysimon commented
The development paradigm this is supporting requires that "deploys" be distinguished outside the codebase - your dev settings shouldn't be in a file at all, but in the environment variables of your development machine. See Factor III.
I do this right now by keeping a python file that lets me quickly set the proper env vars from the terminal, in the parent directory of the repo. My file structure looks like this:
dev
contains all my repos, for all projects I'm working onmyproject-vars-dev.py
sets up the env vars for my devmyproject-vars-[branch].py
contains special env vars for a branch that is differentmyproject\
runserver.py
runs Flask's dev server or production server, based on env varmyproject\
__init__.py