Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
ckanpublish
Commits
f0c22bd9116d
Commit
c1c1e30c
authored
Nov 21, 2014
by
Denis Laxalde
Browse files
[utils] Properly handle ckan-baseurl
In particular, when it does not have a trailing /.
parent
50e1c7ac3e59
Changes
1
Show whitespace changes
Inline
Side-by-side
utils.py
View file @
f0c22bd9
...
...
@@ -16,7 +16,7 @@
"""cubicweb-cg33catsi utilities"""
import
json
from
url
lib
import
base
join
from
url
parse
import
url
join
import
requests
...
...
@@ -28,7 +28,10 @@ class CKANPostError(Exception):
def
ckan_post
(
config
,
action
,
data
=
None
):
url
=
basejoin
(
config
[
'ckan-baseurl'
],
'api/3/action/'
+
action
)
base
=
config
[
'ckan-baseurl'
]
if
not
base
.
endswith
(
'/'
):
base
+=
'/'
url
=
urljoin
(
base
,
'api/3/action/'
+
action
)
headers
=
{
'Authorization'
:
config
[
'ckan-api-key'
],
'Content-Type'
:
'application/json'
}
r
=
requests
.
post
(
url
,
headers
=
headers
,
data
=
json
.
dumps
(
data
or
{}))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment