From a0f69e0f5bf098ab30fb5cabbd8267e722978648 Mon Sep 17 00:00:00 2001 From: Roman Chyla Date: Tue, 23 Aug 2016 11:20:07 -0400 Subject: [PATCH] Make sure to call db.commit() even on non select queries --- adsws/accounts/manage.py | 1 + adsws/accounts/views.py | 4 ++-- setup.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/adsws/accounts/manage.py b/adsws/accounts/manage.py index 4eccf7a..e7ed8b3 100644 --- a/adsws/accounts/manage.py +++ b/adsws/accounts/manage.py @@ -63,6 +63,7 @@ def cleanup_users(app_override=None, timedelta="hours=24"): try: db.session.commit() except Exception, e: + db.session.rollback() app.logger.error("Could not cleanup stale users. " "Database error; rolled back: {0}".format(e)) app.logger.info("Deleted {0} stale users".format(deletions)) diff --git a/adsws/accounts/views.py b/adsws/accounts/views.py index c2d9145..a6a38f6 100644 --- a/adsws/accounts/views.py +++ b/adsws/accounts/views.py @@ -699,7 +699,6 @@ def bootstrap_user(): is_internal=True, ) db.session.add(token) - db.session.commit() current_app.logger.info( "Created BB client for {email}".format(email=current_user.email) ) @@ -708,6 +707,7 @@ def bootstrap_user(): client_id=client.client_id, user_id=current_user.get_id(), ).first() - + + db.session.commit() return client, token diff --git a/setup.py b/setup.py index 8ace51f..edb55a7 100644 --- a/setup.py +++ b/setup.py @@ -73,7 +73,7 @@ def run_tests(self): ADS Web Services ------------------------------------- -Astrophysics Data System (http://adslabs.org) provides the search and +Astrophysics Data System (http://adslabs.org) provides the search and discovery of scientific papers for astrophysics, astronomy and related fields Our services are accessible through the API. And this is the software