From 19e1d5cbeb980566fef66f446411ced6c52fc446 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 17 Mar 2022 09:39:12 +0300 Subject: Provide path to default settings/configuration file as a fallback If the GN2_SETTINGS environment variable, is for some reason, not set, and the application actually ever tries to get a connection to the database, then use the default settings/configuration file. --- wqflask/wqflask/database.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py index 12115e5f..9f659ae6 100644 --- a/wqflask/wqflask/database.py +++ b/wqflask/wqflask/database.py @@ -22,7 +22,10 @@ def read_from_pyfile(pyfile, setting): def sql_uri(): """Read the SQL_URI from the environment or settings file.""" return os.environ.get( - "SQL_URI", read_from_pyfile(os.environ.get("GN2_SETTINGS"), "SQL_URI")) + "SQL_URI", read_from_pyfile( + os.environ.get( + "GN2_SETTINGS", os.path.abspath("../etc/default_settings.py")), + "SQL_URI")) engine = create_engine(sql_uri(), encoding="latin1") -- cgit v1.2.3