Skip to content

Commit

Permalink
Merge branch '1656-fix-paster-db-clean'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hammond committed May 21, 2014
2 parents 15a71ab + f7e9b69 commit 1274492
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ckan/lib/cli.py
Expand Up @@ -111,10 +111,12 @@ def _load_config(self):

self.registry.register(pylons.c, c)

self.site_user = logic.get_action('get_site_user')({'ignore_auth': True}, {})
self.site_user = logic.get_action('get_site_user')({'ignore_auth': True,
'defer_commit': True}, {})

pylons.c.user = self.site_user['name']
pylons.c.userobj = model.User.get(self.site_user['name'])
model.repo.commit_and_remove()

## give routes enough information to run url_for
parsed = urlparse.urlparse(conf.get('ckan.site_url', 'http://0.0.0.0'))
Expand Down
10 changes: 10 additions & 0 deletions ckan/logic/action/get.py
Expand Up @@ -2037,6 +2037,16 @@ def term_translation_show(context, data_dict):

# Only internal services are allowed to call get_site_user.
def get_site_user(context, data_dict):
'''Return the ckan site user
:param defer_commit: by default (or if set to false) get_site_user will
commit and clean up the current transaction, it will also close and
discard the current session in the context. If set to true, caller
is responsible for commiting transaction after get_site_user is
called. Leaving open connections can cause cli commands to hang!
(optional, default: False)
:type defer_commit: boolean
'''
_check_access('get_site_user', context, data_dict)
model = context['model']
site_id = config.get('ckan.site_id', 'ckan_site_user')
Expand Down

0 comments on commit 1274492

Please sign in to comment.