[ckan-changes] commit/ckanclient: dread: Changed default url to thedatahub. www.ckan.net had problem with redirect - explaining problem in error message. Bump version to 0.9.
Bitbucket
commits-noreply at bitbucket.org
Tue Aug 9 17:33:55 UTC 2011
1 new changeset in ckanclient:
http://bitbucket.org/okfn/ckanclient/changeset/ca5295c9c8cf/
changeset: ca5295c9c8cf
user: dread
date: 2011-08-09 19:33:46
summary: Changed default url to thedatahub. www.ckan.net had problem with redirect - explaining problem in error message. Bump version to 0.9.
affected #: 1 file (415 bytes)
--- a/ckanclient/__init__.py Tue Aug 09 18:03:15 2011 +0100
+++ b/ckanclient/__init__.py Tue Aug 09 18:33:46 2011 +0100
@@ -72,6 +72,13 @@
Changelog
=========
+v0.9 2011-XX-XX
+---------------
+
+ * Default URL changed to thedatahub.org
+ * Guard against 301 redirection, which loses POST contents
+
+
v0.8 2011-07-20
---------------
@@ -161,12 +168,12 @@
PAGE_SIZE = 10
-
class CkanApiError(Exception): pass
class CkanApiNotFoundError(CkanApiError): pass
class CkanApiNotAuthorizedError(CkanApiError): pass
class CkanApiConflictError(CkanApiError): pass
+
class ApiRequest(Request):
def __init__(self, url, data=None, headers={}, method=None):
Request.__init__(self, url, data, headers)
@@ -205,6 +212,9 @@
data = urlencode({data: 1})
req = ApiRequest(location, data, headers, method=method)
self.url_response = urlopen(req)
+ if data and self.url_response.geturl() != location:
+ redirection = '%s -> %s' % (location, self.url_response.geturl())
+ raise URLError("Got redirected to another URL, which does not work with POSTS. Redirection: %s" % redirection)
except HTTPError, inst:
self._print("ckanclient: Received HTTP error code from CKAN resource.")
self._print("ckanclient: location: %s" % location)
@@ -283,13 +293,13 @@
"""
Client API implementation for CKAN.
- :param base_location: default *http://www.ckan.net/api*
+ :param base_location: default *http://thedatahub.org/api*
:param api_key: default *None*
:param is_verbose: default *False*
:param http_user: default *None*
:param http_pass: default *None*
"""
- base_location = 'http://www.ckan.net/api'
+ base_location = 'http://thedatahub.org/api'
resource_paths = {
'Base': '',
'Changeset Register': '/rest/changeset',
Repository URL: https://bitbucket.org/okfn/ckanclient/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list