diff --git a/modules/base/config.py b/modules/base/config.py index af908206a4e0ac22881576e89bdece4edc60b292..afba671cba6e8db2347852e1e3adc89f19ff6be7 100644 --- a/modules/base/config.py +++ b/modules/base/config.py @@ -32,6 +32,7 @@ class AuraConfig: Holds the Engine Configuration as in the file `engine.ini`. """ + instance = None ini_path = "" logger = None @@ -52,6 +53,7 @@ class AuraConfig: self.ini_path = ini_path self.load_config() + AuraConfig.instance = self # Defaults self.set("config_dir", os.path.dirname(ini_path)) @@ -60,6 +62,15 @@ class AuraConfig: + @staticmethod + def config(): + """ + Retrieves the global instances of the configuration. + """ + return AuraConfig.instance + + + def set(self, key, value): """ Setter for some specific config property. @@ -111,6 +122,19 @@ class AuraConfig: + def get_database_uri(self): + """ + Retrieves the database connection string. + """ + db_name = self.get("db_name") + db_user = self.get("db_user") + db_pass = str(self.get("db_pass")) + db_host = self.get("db_host") + db_charset = self.get("db_charset", "utf8") + return "mysql://" + db_user + ":" + db_pass + "@" + db_host + "/" + db_name + "?charset=" + db_charset + + + def load_config(self): """ Set config defaults and load settings from file @@ -138,15 +162,3 @@ class AuraConfig: self.set(key, v) - - - def get_database_uri(self): - """ - Retrieves the database connection string. - """ - db_name = self.get("db_name") - db_user = self.get("db_user") - db_pass = str(self.get("db_pass")) - db_host = self.get("db_host") - db_charset = self.get("db_charset", "utf8") - return "mysql://" + db_user + ":" + db_pass + "@" + db_host + "/" + db_name + "?charset=" + db_charset \ No newline at end of file