[#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.
This commit is contained in:
amercader 2013-05-30 18:06:15 +01:00
parent ff7287d4b4
commit 361abcfc07
1 changed files with 7 additions and 4 deletions

View File

@ -247,11 +247,14 @@ class CKANHarvester(HarvesterBase):
package_dict['tags'] = [] package_dict['tags'] = []
package_dict['tags'].extend([t for t in default_tags if t not in 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) 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 # check if remote groups exist locally, otherwise remove
validated_groups = [] validated_groups = []
context = {'model': model, 'session': Session, 'user': 'harvest'} context = {'model': model, 'session': Session, 'user': 'harvest'}