From fad6e5c2302811e8721123fa8e7f43a5bdecb068 Mon Sep 17 00:00:00 2001 From: Roman Podoliaka Date: Wed, 21 May 2014 10:57:32 +0300 Subject: 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 --- doc/source/usage.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'doc/source/usage.rst') 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() -- cgit v1.2.1