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

Validate required settings after loading all settings #32

Closed
dirn opened this issue Feb 17, 2014 · 0 comments · Fixed by #35
Closed

Validate required settings after loading all settings #32

dirn opened this issue Feb 17, 2014 · 0 comments · Fixed by #35
Assignees

Comments

@dirn
Copy link
Contributor

dirn commented Feb 17, 2014

Currently required settings are checked inside settings.py. While this does a great job of enforcing the presence of environment settings, there are two additional ways to load settings.

It would be setting to move the checks for required settings to factory.py after all three settings types have been loaded.

Something along the lines of

app.config.from_object('nycpython.settings')
app.config.from_pyfile('settings.cfg', silent=True)
app.config.from_object(settings_override)
check_required_settings(app.config)

The function definition belongs in utils.py.

@dirn dirn self-assigned this Feb 21, 2014
dirn added a commit that referenced this issue Feb 26, 2014
Certain settings are going to be required for the application to run.
Currently `SECRET_KEY` is the only one, but the list will most likely
grow over time. The application factory allows for the settings in
`settings.py` to be overridden a couple of different ways. Required
settings should be checked after all of the overrides have been
processed.

This is being implemented in the form of a helper function that checks
for the required keys. Because `settings.py` will add the key to the
configuration, `DOES_NOT_EXIST` is a value that can be assigned to a key
that is intended to be required. `check_required_settings` will respect
both the absence of the key and the value `DOES_NOT_EXIST`.

Along with this change comes some tests. These two tests are the
groundwork for the eventual suite of tests. `tox` can be used to run the
tests. `tox` requires a `setup.py` in order to install the package into
the virtualenv, so a minimal one is being added for that purpose.

Fixes #32
dirn added a commit that referenced this issue Feb 26, 2014
Certain settings are going to be required for the application to run.
Currently `SECRET_KEY` is the only one, but the list will most likely
grow over time. The application factory allows for the settings in
`settings.py` to be overridden a couple of different ways. Required
settings should be checked after all of the overrides have been
processed.

This is being implemented in the form of a helper function that checks
for the required keys. Because `settings.py` will add the key to the
configuration, `DOES_NOT_EXIST` is a value that can be assigned to a key
that is intended to be required. `check_required_settings` will respect
both the absence of the key and the value `DOES_NOT_EXIST`.

Along with this change comes some tests. These two tests are the
groundwork for the eventual suite of tests. `tox` can be used to run the
tests. `tox` requires a `setup.py` in order to install the package into
the virtualenv, so a minimal one is being added for that purpose.

Fixes #32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant