Make get_session() pass kwargs to a sessionmaker
get_session() method is used to construct a new SQLAlchemy session instance. Currently, it takes two keyword arguments which are used to configure the Session instance to be created. Actually, there are more arguments which can be passed to a sessiomaker instance. oslo.db should not stay in the way of a developer who wants to use specific features of SQLAlchemy session: it should handle oslo.db specific arguments and pass keyword arguments as is when calling the sessionmaker. Change-Id: I1f577a30586eafe1295bcbd15a6a881e9f7f65ab
This commit is contained in:
parent
fad6e5c230
commit
28df4edde0
|
@ -859,21 +859,12 @@ class EngineFacade(object):
|
|||
def get_session(self, **kwargs):
|
||||
"""Get a Session instance.
|
||||
|
||||
If passed, keyword arguments values override the ones used when the
|
||||
sessionmaker instance was created.
|
||||
|
||||
:keyword autocommit: use autocommit mode for created Session instances
|
||||
:type autocommit: bool
|
||||
|
||||
:keyword expire_on_commit: expire session objects on commit
|
||||
:type expire_on_commit: bool
|
||||
Keyword arugments will be passed to a sessionmaker instance as is (if
|
||||
passed, they will override the ones used when the sessionmaker instance
|
||||
was created). See SQLAlchemy Session docs for details.
|
||||
|
||||
"""
|
||||
|
||||
for arg in kwargs:
|
||||
if arg not in ('autocommit', 'expire_on_commit'):
|
||||
del kwargs[arg]
|
||||
|
||||
return self._session_maker(**kwargs)
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in New Issue