In order to be able to use openstf-dbc with a different configuration mechanism the data interface need to be decoupled from the config manager. This PR implements this decoupling.
The DataBase() needs to be called with a config argument once
The _DataInterface() needs to be called with a config argument once
Both are now singleton classes and can only have one instance
A warning is printed when making multiple init calls with arguments (since argument will only be used the first time)
All other projects that use openstf-dbc need to do the following:
# When calling the database for the first time pass in the configuration:
from openstf_dbc.database import DataBase
# first call needs configuration
db = DataBase(config)
# All other calls don't need configuration
def some_function():
db = DataBase()
I've chosen for DataBase(config) and DataBase() for simplicity and backwards compatibility. But alternatively more input arguments can be used to be more explicit.
Let me know what you think and if this a good approach for decoupling the data interface (and database) and config manager.
In order to be able to use
openstf-dbc
with a different configuration mechanism the data interface need to be decoupled from the config manager. This PR implements this decoupling.DataBase()
needs to be called with aconfig
argument once_DataInterface()
needs to be called with aconfig
argument onceAll other projects that use
openstf-dbc
need to do the following:I've chosen for
DataBase(config)
andDataBase()
for simplicity and backwards compatibility. But alternatively more input arguments can be used to be more explicit.Let me know what you think and if this a good approach for decoupling the data interface (and database) and config manager.