aboutsummaryrefslogtreecommitdiff
path: root/budget/run.py
diff options
context:
space:
mode:
authorJocelyn Delande <jocelyn@crapouillou.net>2015-08-19 22:40:07 +0200
committerJocelyn Delande <jocelyn@crapouillou.net>2015-08-19 22:53:16 +0200
commitd6c514e7d176fcdf6be3e3ca6eb05ea2ea725d71 (patch)
tree7e57172b56ccce85759b5c3542599c7cc098ba5e /budget/run.py
parent0e21449191ee54d72392c11e257e8bb1f7a8f625 (diff)
downloadihatemoney-mirror-d6c514e7d176fcdf6be3e3ca6eb05ea2ea725d71.zip
ihatemoney-mirror-d6c514e7d176fcdf6be3e3ca6eb05ea2ea725d71.tar.gz
ihatemoney-mirror-d6c514e7d176fcdf6be3e3ca6eb05ea2ea725d71.tar.bz2
Adds a way to (re)configure the running app, reloading settings.
Currently, there is no way to reset settings after modifying them, which is anoying for tests.
Diffstat (limited to 'budget/run.py')
-rw-r--r--budget/run.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/budget/run.py b/budget/run.py
index 1a65022..2e18599 100644
--- a/budget/run.py
+++ b/budget/run.py
@@ -9,18 +9,25 @@ from api import api
app = Flask(__name__)
-app.config.from_object("default_settings")
-
-# Deprecations
-if 'DEFAULT_MAIL_SENDER' in app.config:
- # Since flask-mail 0.8
- warnings.warn(
- "DEFAULT_MAIL_SENDER is deprecated in favor of MAIL_DEFAULT_SENDER"
- +" and will be removed in further version",
- UserWarning
- )
- if not 'MAIL_DEFAULT_SENDER' in app.config:
- app.config['MAIL_DEFAULT_SENDER'] = DEFAULT_MAIL_SENDER
+
+
+def configure():
+ """ A way to (re)configure the app, specially reset the settings
+ """
+ app.config.from_object("default_settings")
+
+ # Deprecations
+ if 'DEFAULT_MAIL_SENDER' in app.config:
+ # Since flask-mail 0.8
+ warnings.warn(
+ "DEFAULT_MAIL_SENDER is deprecated in favor of MAIL_DEFAULT_SENDER"
+ +" and will be removed in further version",
+ UserWarning
+ )
+ if not 'MAIL_DEFAULT_SENDER' in app.config:
+ app.config['MAIL_DEFAULT_SENDER'] = DEFAULT_MAIL_SENDER
+
+configure()
app.register_blueprint(main)