Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration Support #17

Closed
mitsuhiko opened this issue Apr 27, 2010 · 6 comments
Closed

Configuration Support #17

mitsuhiko opened this issue Apr 27, 2010 · 6 comments

Comments

@mitsuhiko
Copy link
Contributor

Apps should have some kind of config dict attached. That would make it a lot cleaner to deal with configuration values.

@danjac
Copy link

danjac commented May 2, 2010

It would be useful to be able to have "config" as a threadlocal or global object. For example:

config = dict("some_value"="xyz")
app = Flask(__name__, config=config)

And elsewhere in your code:

from flask import config

@app.route("/")
def index():
    assert config['some_value'] == 'xyz'

@mitsuhiko
Copy link
Contributor Author

I was thinking of just attaching that to app. Then you can do app.config or if you don't know the current application you can do current_app.config.

@danjac
Copy link

danjac commented May 2, 2010

As long as I can use current_app to avoid circular dependencies that should work fine.

@danjac
Copy link

danjac commented May 5, 2010

Another thing to consider is the ability to override the default configuration easily in unit tests, where you want to use a test database and other safe settings.

@mitsuhiko
Copy link
Contributor Author

There is now a branch for this: http://github.com/mitsuhiko/flask/tree/config-support

Outstanding issues:

  1. Configuration keys not documented
  2. Unsure about where and how to document that
  3. Document config keys as SECRET_KEY or secret_key?

@mitsuhiko
Copy link
Contributor Author

Implemented :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
This issue was closed.
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

2 participants