From 45b25809ea45652648b4f735345f1f43abcce985 Mon Sep 17 00:00:00 2001 From: Pieter Colpaert Date: Wed, 11 Dec 2013 00:44:58 +0000 Subject: [PATCH] fixed #1 after testing --- ckanext/tdt/plugin.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ckanext/tdt/plugin.py b/ckanext/tdt/plugin.py index 621b066..e476a93 100644 --- a/ckanext/tdt/plugin.py +++ b/ckanext/tdt/plugin.py @@ -50,7 +50,7 @@ def can_preview(self, data_dict): if(rname == ""): rname = "unnamed" tdt_uri = self.tdt_host + "/ckan/" + rid + "/" + rname - r = requests.head(tdt_uri) + r = requests.get(tdt_uri) log.info(r.status_code) return r.status_code == 200 @@ -73,15 +73,17 @@ def create_tdt_source(self, entity): if(entity.name == ""): entity.name = "unnamed" tdt_uri = self.tdt_host + "/api/definitions/ckan/" + entity.id + "/" + entity.name + log.info(tdt_uri) r = requests.put(tdt_uri, auth=(self.tdt_user, self.tdt_pass), - data="{'description':'" + entity.description +"','uri':'" + entity.url + "'}", + data=json.dumps({'description': entity.description,'uri':entity.url }), headers={'Content-Type' : 'application/tdt.' + entity.format.lower() }) if(r.status_code == 200): log.info(r.headers["content-location"]) elif (r.status_code > 200): - log.error("Could not add dataset \""+ entity.name +"\" to The DataTank") + log.error("Could not add dataset - \""+ entity.name +"\" - to The DataTank") + log.error("This is the error message: " + r.text) log.error(r.status_code) return