Add basic support for Trainwreck database connectivity

This commit is contained in:
Lance Edgar 2017-05-12 23:14:30 -05:00
parent 17f9e6d4a9
commit f02d6d4b16
2 changed files with 5 additions and 0 deletions

View file

@ -89,6 +89,8 @@ def make_rattail_config(settings):
tailbone.db.Session.configure(bind=rattail_engines['default'])
if hasattr(rattail_config, 'tempmon_engine'):
tailbone.db.TempmonSession.configure(bind=rattail_config.tempmon_engine)
if hasattr(rattail_config, 'trainwreck_engine'):
tailbone.db.TrainwreckSession.configure(bind=rattail_config.trainwreck_engine)
# Make sure rattail config object uses our scoped session, to avoid
# unnecessary connections (and pooling limits).

View file

@ -39,6 +39,7 @@ Session = scoped_session(sessionmaker(class_=SessionBase, rattail_config=None, r
# not necessarily used, but here if you need it
TempmonSession = scoped_session(sessionmaker())
TrainwreckSession = scoped_session(sessionmaker())
class TailboneSessionDataManager(datamanager.SessionDataManager):
@ -148,6 +149,8 @@ def register(session, initial_state=datamanager.STATUS_ACTIVE,
if tuple(int(x) for x in sa.__version__.split('.')) >= (0, 7):
register(Session)
register(TempmonSession)
register(TrainwreckSession)
else:
Session.configure(extension=ZopeTransactionExtension())
TempmonSession.configure(extension=ZopeTransactionExtension())
TrainwreckSession.configure(extension=ZopeTransactionExtension())