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

Support loading configuration from text files #3398

Merged
merged 2 commits into from
Oct 18, 2019
Merged

Conversation

pgjones
Copy link
Member

@pgjones pgjones commented Oct 15, 2019

TOML is a very popular format now, and is taking hold in the Python
ecosystem via pyproject.toml (among others). This allows toml config
files via,

app.config.from_file("config.toml", toml.loads)

it also allows for any other file format whereby there is a loader
that takes a string and returns a mapping.

This is an alternative to #3386.

src/flask/config.py Outdated Show resolved Hide resolved
src/flask/config.py Outdated Show resolved Hide resolved
tests/test_config.py Show resolved Hide resolved
tests/test_config.py Show resolved Hide resolved
@davidism
Copy link
Member

I'm not sure if it's worth pulling in TOML just for one test. Can this be tested with json.load instead?

@pgjones
Copy link
Member Author

pgjones commented Oct 16, 2019

I've moved the toml example to the docs (from the tests).

@davidism davidism added this to the 2.0.0 milestone Oct 18, 2019
TOML is a very popular format now, and is taking hold in the Python
ecosystem via pyproject.toml (among others). This allows toml config
files via,

    app.config.from_file("config.toml", toml.loads)

it also allows for any other file format whereby there is a loader
that takes a string and returns a mapping.
@davidism davidism merged commit 8f422d2 into pallets:master Oct 18, 2019
@pgjones pgjones deleted the toml branch October 18, 2019 16:56
pgjones added a commit to pallets/quart that referenced this pull request Oct 18, 2019
This alters e49d4f6 and follows
discussion in Flask about how best to support this functionality. With
this change Quart matches the Flask functionality.

See pallets/flask#3398.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
2 participants