From 361abcfc07a20b0fd874d970ec45b3107eccff75 Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 30 May 2013 18:06:15 +0100 Subject: [PATCH] [#17] Fix bug with remote groups handling If neither 'only_local' or 'create' are used the remote groups property needs to be removed, otherwise it causes an exception when the group is not found. --- ckanext/harvest/harvesters/ckanharvester.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ckanext/harvest/harvesters/ckanharvester.py b/ckanext/harvest/harvesters/ckanharvester.py index 3920cf7..981864d 100644 --- a/ckanext/harvest/harvesters/ckanharvester.py +++ b/ckanext/harvest/harvesters/ckanharvester.py @@ -247,11 +247,14 @@ class CKANHarvester(HarvesterBase): package_dict['tags'] = [] package_dict['tags'].extend([t for t in default_tags if t not in package_dict['tags']]) - if not 'groups' in package_dict: - package_dict['groups'] = [] - remote_groups = self.config.get('remote_groups', None) - if remote_groups in ('only_local', 'create'): + if not remote_groups in ('only_local', 'create'): + # Ignore remote groups + package_dict.pop('groups', None) + else: + if not 'groups' in package_dict: + package_dict['groups'] = [] + # check if remote groups exist locally, otherwise remove validated_groups = [] context = {'model': model, 'session': Session, 'user': 'harvest'}