[ckan-dev] A new ckan client library: ckanapi

Heinrich Widmann widmann at dkrz.de
Wed Apr 24 18:53:13 UTC 2013


Hi Ian,

Am 24.04.2013 18:57, schrieb Ian Ward:
> On Wed, Apr 24, 2013 at 7:28 AM, John Mrziglod <mrzo at gmx.de 
> <mailto:mrzo at gmx.de>> wrote:
>
>     response = ckan_object.call_action(action,object);
>     It works fine by using 'action=package_update' with default
>     fields, e.g.:
>     object = {"name":"extratest","title":"Test with Extras"}
>     But what I need is an update with an extras data field, i.e.:
>     object = {"name":"extratest","title":"Test with Extras","extras":
>     [{"key": "config",  "value": "xxx"}]}
>
>
> That looks about right, but it's always nicer to see actual code.
Our python script is attached ... and test json-data in file ddd
> What happens when you do this, the extras just don't appear?
Try e.g. (of course you have to set before your ckan instance (iphost) 
and the api_key :

 > ckan_api.py -a package_create -f ddd
....
[ERROR] Name is not valid !

(Don't know what it's wrong with the name 
'echam5_mpi-om_dmi_eh5_run4_a1b_sfc' ? )

and
 > ckan_api.py -a package_update -f ddd

hangs for ever and nothing happens ...
>
> BTW, ckanapi just json encodes everything passed and sends them to the 
> action, it doesn't have any specific handling for package_update or 
> any other action.
Ok, then what should be used just to do some really basic things :

1. create a data set (just with default keys 'author' and 'maintainer')
2. update new meta data (key:value pairs) to the data set (as well 
extras-fields)
3. add the dataset to a group

Likely we go in the total wrong direction - but I'm pretty sure, that 
there is an easy way or perform this simple upload actions with the CKAN 
APIs !?

Maybe you can send us a python code, that performs at least the create 
and update step ?
This would help a lot !

Heinrich
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20130424/28eb1daf/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ckan_api2.py
Type: text/x-python
Size: 3942 bytes
Desc: not available
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20130424/28eb1daf/attachment-0003.py>
-------------- next part --------------
{"name": "echam5_mpi-om_dmi_eh5_run4_a1b_sfc", "maintainer": "May, Wilhelm", "author": "Winkelmann, Volker", "url": "None", "notes": "The data represent 6 hourly values of selected variables for the Data Distribution\t\t\t\t    Centre (DDC) of the Intergovermental Panel on Climate Change (IPCC). (see also: \t\t\t\t    http://ipcc-ddc.cru.uea.ac.uk) The A1B scenario is the part of the A1 family which\t\t\t\t    describes a balance across all energy sources. The experiment has been initialized in year\t\t\t\t\t2000 of the 20C_1 run and continues until year 2100 with anthropogenic forcings (CO2, CH4, N2O,\t\t\t\t    CFCs, O3 and sulfate) according to A1B. The\texperiment is extended until year 2200 with all\t\t\t\t    concentrations fixed at their levels of year 2100 (stabilization experiment).", "title": "ECHAM5/MPI-OM DMI_EH5_Run4_A1B SFC", "version": "network Common Data Format", "date": "2004-09-13T15:52:00", "extras": [ { "key": "config",  "value": "xxx" } ] }


More information about the ckan-dev mailing list