From 2a07a144fc35222acecf040b8e234c4dd776c014 Mon Sep 17 00:00:00 2001 From: amercader Date: Mon, 10 Feb 2014 18:22:48 +0000 Subject: [PATCH] [#84] Fix auth audit exception when creating datasets This was caused by a combination of the auth audit leaking and the harvester reusing the context for the package_show and package_create actions. If the package is not found, package_show does not call check_access, and the auth audit does not pass. This is stored in the context (`__auth_audit`) and is raised next time that we call get_action (when we call package_create with the same context) It could potentially be fixed on master, but it is probably quite rare. --- ckanext/harvest/harvesters/base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ckanext/harvest/harvesters/base.py b/ckanext/harvest/harvesters/base.py index 35c1881..da2fb1b 100644 --- a/ckanext/harvest/harvesters/base.py +++ b/ckanext/harvest/harvesters/base.py @@ -193,6 +193,10 @@ class HarvesterBase(SingletonPlugin): except NotFound: # Package needs to be created + # Get rid of auth audit on the context otherwise we'll get an + # exception + context.pop('__auth_audit', None) + # Set name if not already there package_dict.setdefault('name', self._gen_new_name(package_dict['title']))