Merge "context: Warn on mixed uses of old and new db methods"
This commit is contained in:
commit
9da2f19f54
|
@ -15,6 +15,7 @@
|
|||
import collections
|
||||
import copy
|
||||
import datetime
|
||||
import warnings
|
||||
|
||||
from oslo_context import context as oslo_context
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
|
@ -145,6 +146,11 @@ class Context(ContextBaseWithSession):
|
|||
# TODO(akamyshnikova): checking for session attribute won't be needed
|
||||
# when reader and writer will be used
|
||||
if hasattr(super(Context, self), 'session'):
|
||||
if self._session:
|
||||
warnings.warn('context.session is used with and without '
|
||||
'new enginefacade. Please update the code to '
|
||||
'use new enginefacede consistently.',
|
||||
DeprecationWarning)
|
||||
return super(Context, self).session
|
||||
if self._session is None:
|
||||
self._session = db_api.get_writer_session()
|
||||
|
|
Loading…
Reference in New Issue