From de20ab3834f2a84fd3f2ba9657650e28898e27f0 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 23 Mar 2023 09:12:53 +0300 Subject: conf: use flask.current_app.config not in gn3.settings The configuration in gn3.settings can (and does) get overwritten by values in the environment variable `GN3_CONF` and any configurations passed in the call to the `gn3.app.create_app` function; as such, this commit changes the configuration used in the code to user the final configuration values that are in the running application's `flask.current_app.config` object. --- gn3/db_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gn3') diff --git a/gn3/db_utils.py b/gn3/db_utils.py index ad934d7..862d76c 100644 --- a/gn3/db_utils.py +++ b/gn3/db_utils.py @@ -4,14 +4,14 @@ from typing import Any, Iterator, Protocol, Tuple from urllib.parse import urlparse import MySQLdb as mdb import xapian -from gn3.settings import SQL_URI +from flask import current_app def parse_db_url() -> Tuple: """function to parse SQL_URI env variable note:there\ is a default value for SQL_URI so a tuple result is\ always expected""" - parsed_db = urlparse(SQL_URI) + parsed_db = urlparse(current_app.config["SQL_URI"]) return ( parsed_db.hostname, parsed_db.username, parsed_db.password, parsed_db.path[1:], parsed_db.port) -- cgit v1.2.3