Skip to content

Commit

Permalink
50char->| 72char->|
Browse files Browse the repository at this point in the history
Add support for .env file. Close Issue zerasul#32.

This Pull Request adds support to define blask settings using a .env
file.

**Usage**

Add an .env file in the root folder defining the variables FLASK_APP,
templateDir, postDir, defaultLayout, staticDir, title.
(Use .env.example as template)

`$ pipenv shell` will launch the virtualenv and automatically create
environment variables from .env

**Behaviour**

In order to ensure backwards compatibility, the following precedence is
considered to define blask settings:

1. if the environment variable BLASK_SETTINGS exists, the settings are
   loaded from this module (e.g. settings.py)
2. otherwise, environment variables, and finally default values are used
3. in any case, whenever Blask() is called with arguments, they always
   take precedence

**Description of changes**

* blask/blasksettings.py - in `BlaskSettings.__init__()``, replace
  default settings with environment variables. Add clarifications to
  docstring and comments.

* blask/blaskcli.py - fix typos in comments and docstrings, minor code
  formatting

* tests/settings_test.py - temporarily delete environment variables
  before the tests and restore them afterwards.
  Add test_from_dotenv() to test with environment variables

All tests passed.

Close zerasul#32.
  • Loading branch information
mhered committed Oct 17, 2021
1 parent 7e31395 commit 919c611
Show file tree
Hide file tree
Showing 5 changed files with 750 additions and 18 deletions.
Loading

0 comments on commit 919c611

Please sign in to comment.