Skip to content

Commit

Permalink
Expose the two DB engines
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Valsecchi committed Feb 1, 2017
1 parent ffa02bc commit 5702fb2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion acceptance_tests/app/c2cwsgiutils_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def init(config):
global DBSession
DBSession = db.setup_session(config, 'sqlalchemy', 'sqlalchemy_slave', force_slave=[
"POST /api/hello"
])
])[0]


class Hello(Base):
Expand Down
4 changes: 2 additions & 2 deletions c2cwsgiutils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def setup_session(config, master_prefix, slave_prefix="", force_master=None, for
settings
:param force_master: The method/paths that needs to use the master
:param force_slave: The method/paths that needs to use the slave
:return: The SQLAlchemy session
:return: The SQLAlchemy session, the R/W engine and the R/O engine
"""
def db_chooser_tween_factory(handler, registry):
"""
Expand Down Expand Up @@ -78,4 +78,4 @@ def db_chooser_tween(request):

db_session = sqlalchemy.orm.scoped_session(
sqlalchemy.orm.sessionmaker(extension=ZopeTransactionExtension(), bind=rw_engine))
return db_session
return db_session, rw_engine, ro_engine

0 comments on commit 5702fb2

Please sign in to comment.