Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Make init_for calls automatic #6

Closed
jace opened this issue May 3, 2017 · 3 comments
Closed

Make init_for calls automatic #6

jace opened this issue May 3, 2017 · 3 comments

Comments

@jace
Copy link
Member

jace commented May 3, 2017

hgapp-based apps currently require init_for to be called explicitly. The Flask extension ecosystem however expects init to happen implicitly during module load and often provides no hook for config to be loaded.

We should switch to implicit config by (a) reading an environment variable named FLASK_ENV for the expected environment (default dev) and (b) call it at the bottom of __init__.py itself, instead of having an external caller (runserver.py, website.py, etc).

Coaster's manage.py expects env and init_for parameters. Those must be removed. This therefore requires a coordinated switch across all repositories.

Production deployments must have export FLASK_ENV="production" specified somewhere globally, like in /etc/rc.local.

@jace
Copy link
Member Author

jace commented May 4, 2017

The Flask-Environments extension, which does something similar, uses DEVELOPMENT as the default value. We currently expect lowercase in app.py, but (a) we can switch to case insensitive, and (b) for the sake of compatibility, specify upper case DEVELOPMENT as the default value.

Further, defaults should be specified in a single place, so this should be in the init_app function.

@jace
Copy link
Member Author

jace commented May 4, 2017

Please file issues in all apps with the same title and the following text:

Refer to hasgeek/hgapp#6

@jace
Copy link
Member Author

jace commented May 4, 2017

If we move the parsing of FLASK_ENV into Coaster, the init_for function itself is unnecessary and all config can move inline.

jace added a commit that referenced this issue May 4, 2017
Please use this commit’s changes as the template for changes to all
apps.
@jace jace closed this as completed in 95306e6 May 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant