From 935b9dda0100325028b01eb45a363b5730670c16 Mon Sep 17 00:00:00 2001 From: Stefan Oderbolz Date: Thu, 15 Jan 2015 00:09:43 +0100 Subject: [PATCH] Munge group name before fetching remote group The API call /api/2/rest/package/ returns the display name of the group instead of its ID. To properly match the group, munge the name before calling /api/2/rest/group --- ckanext/harvest/harvesters/ckanharvester.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ckanext/harvest/harvesters/ckanharvester.py b/ckanext/harvest/harvesters/ckanharvester.py index e6fe503..a5b3f32 100644 --- a/ckanext/harvest/harvesters/ckanharvester.py +++ b/ckanext/harvest/harvesters/ckanharvester.py @@ -5,6 +5,7 @@ from ckan import model from ckan.model import Session, Package from ckan.logic import ValidationError, NotFound, get_action from ckan.lib.helpers import json +from ckan.lib.munge import munge_name from ckanext.harvest.model import HarvestJob, HarvestObject, HarvestGatherError, \ HarvestObjectError @@ -51,7 +52,7 @@ class CKANHarvester(HarvesterBase): return http_response.read() def _get_group(self, base_url, group_name): - url = base_url + self._get_rest_api_offset() + '/group/' + group_name + url = base_url + self._get_rest_api_offset() + '/group/' + munge_name(group_name) try: content = self._get_content(url) return json.loads(content)