Merge "Add legacy get_sessionmaker() method"

This commit is contained in:
Jenkins 2015-07-01 09:39:52 +00:00 committed by Gerrit Code Review
commit 432812794e
2 changed files with 19 additions and 0 deletions

View File

@ -964,6 +964,18 @@ class LegacyEngineFacade(object):
else:
return self._factory._writer_maker(**kwargs)
def get_sessionmaker(self, use_slave=False):
"""Get the sessionmaker instance used to create a Session.
This can be called for those cases where the sessionmaker() is to
be temporarily injected with some state such as a specific connection.
"""
if use_slave:
return self._factory._reader_maker
else:
return self._factory._writer_maker
@classmethod
def from_config(cls, conf,
sqlite_fk=False, autocommit=True, expire_on_commit=False):

View File

@ -947,6 +947,13 @@ class LegacyIntegrationtest(test_base.DbTestCase):
enginefacade.get_legacy_facade() is legacy_facade
)
def test_get_sessionmaker(self):
legacy_facade = enginefacade.get_legacy_facade()
self.assertTrue(
legacy_facade.get_sessionmaker() is
enginefacade._context_manager._factory._writer_maker
)
class ThreadingTest(test_base.DbTestCase):
"""Test copying on new threads using real connections and sessions."""