From e60c59e8db9510cf9554966e26119388a3aa3dfd Mon Sep 17 00:00:00 2001 From: kindly Date: Tue, 23 Jul 2013 11:19:12 +0100 Subject: [PATCH] fix paster db clean --- ckan/config/environment.py | 3 +++ ckan/logic/action/get.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ckan/config/environment.py b/ckan/config/environment.py index 7a2dd27682d..4b9bb8f6d9d 100644 --- a/ckan/config/environment.py +++ b/ckan/config/environment.py @@ -356,3 +356,6 @@ def genshi_lookup_attr(cls, obj, key): except sqlalchemy.exc.ProgrammingError: # The database is not initialised. This is a bit dirty. pass + # if an extension or our code does not finish + # transaction properly db cli commands can fail + model.Session.remove() diff --git a/ckan/logic/action/get.py b/ckan/logic/action/get.py index 829b6cc5f65..65a9aef5110 100644 --- a/ckan/logic/action/get.py +++ b/ckan/logic/action/get.py @@ -1843,8 +1843,9 @@ def get_site_user(context, data_dict): user.sysadmin = True model.Session.add(user) model.Session.flush() - if not context.get('defer_commit'): - model.Session.commit() + if not context.get('defer_commit'): + model.repo.commit_and_remove() + return {'name': user.name, 'apikey': user.apikey}