summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRoman Podoliaka <rpodolyaka@mirantis.com>2014-05-21 10:57:32 +0300
committerRoman Podoliaka <rpodolyaka@mirantis.com>2014-05-27 15:58:22 +0300
commitfad6e5c2302811e8721123fa8e7f43a5bdecb068 (patch)
treee79ba24d3631ae2eed7c4a67e5eba173c1d1c2e8 /doc
parent6f64c83363651a6bafcefebee4f66f3ddb722d1e (diff)
downloadoslo-db-fad6e5c2302811e8721123fa8e7f43a5bdecb068.tar.gz
Fix usage of oslo.config
- make it possible to create a DBAPI instance given a config instance - remove usage of global cfg.CONF instance (it's up to a user to pass a ConfigOpts instance to oslo.db) - ensure end applications don't need to import/register/use config options directly - instead they pass a config instance to oslo.db helpers (EngineFacade.from_config() and DBAPI.from_config() class methods) At the same time, usage of oslo.config remains completely optional as we provide an API to pass those parameters programatically. Change-Id: I1a00db7a4200ebdc96f17256ecbad430477e868f
Diffstat (limited to 'doc')
-rw-r--r--doc/source/usage.rst8
1 files changed, 3 insertions, 5 deletions
diff --git a/doc/source/usage.rst b/doc/source/usage.rst
index be9ff69..0e5a2f2 100644
--- a/doc/source/usage.rst
+++ b/doc/source/usage.rst
@@ -8,6 +8,7 @@ To use oslo.db in a project::
.. code:: python
+ from oslo.config import cfg
from oslo.db.sqlalchemy import session as db_session
_FACADE = None
@@ -15,8 +16,7 @@ To use oslo.db in a project::
def _create_facade_lazily():
global _FACADE
if _FACADE is None:
- _FACADE = db_session.EngineFacade.from_config(
- CONF.database.connection, CONF)
+ _FACADE = db_session.EngineFacade.from_config(cfg.CONF)
return _FACADE
def get_engine():
@@ -48,12 +48,10 @@ To use oslo.db in a project::
from oslo.config import cfg
from oslo.db import api as db_api
- CONF = cfg.CONF
- CONF.import_opt('backend', 'oslo.db.options', group='database')
_BACKEND_MAPPING = {'sqlalchemy': 'project.db.sqlalchemy.api'}
- IMPL = db_api.DBAPI(CONF.database.backend, backend_mapping=_BACKEND_MAPPING)
+ IMPL = db_api.DBAPI.from_config(cfg.CONF, backend_mapping=_BACKEND_MAPPING)
def get_engine():
return IMPL.get_engine()