From a315095a1a42ffbf866805867a3e9a309bc46147 Mon Sep 17 00:00:00 2001 From: Matt Jia Date: Mar 28 2017 04:01:21 +0000 Subject: workaround for the flask-sqlalchemy issue #364 This patch also cleans up the code to make tox happy. --- diff --git a/tests/test_app.py b/tests/test_app.py index a065711..3055c3a 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -18,6 +18,7 @@ from __future__ import unicode_literals import mock from waiverdb import app, config +from flask_sqlalchemy import SignallingSession class NoZmqConfig(config.Config): @@ -38,4 +39,4 @@ def test_register_events_no_zmq(mock_listen): def test_register_events_zmq(mock_listen): app.create_app(ZmqConfig) mock_listen.assert_called_once_with( - app.db.session, 'after_commit', app.fedmsg_new_waiver) + SignallingSession, 'after_commit', app.fedmsg_new_waiver) diff --git a/waiverdb/app.py b/waiverdb/app.py index 537c69e..3e31b45 100644 --- a/waiverdb/app.py +++ b/waiverdb/app.py @@ -73,4 +73,7 @@ def register_event_handlers(app): attached as the ``session`` attribute. """ if app.config['ZEROMQ_PUBLISH']: - event.listen(db.session, 'after_commit', fedmsg_new_waiver) + # A workaround for https://github.com/mitsuhiko/flask-sqlalchemy/pull/364 + # can be removed after python-flask-sqlalchemy is upgraded to 2.2 + from flask_sqlalchemy import SignallingSession + event.listen(SignallingSession, 'after_commit', fedmsg_new_waiver)