[ckan-dev] Confused on response['success'] and HTTP status codes with empty results

Sean Hammond sean.hammond at okfn.org
Mon Apr 1 20:48:24 UTC 2013


> This is how a basic function looks like in libckan:
> 
> ---
> def name_action(client=client.Client(), id=''):
>     resp = client.request(action='name_action', data=args)
>     if not resp['success']:
>         raise exceptions.CKANError(resp.error)
>     return resp
> ---

My worry about this is that it looks like you've implemented a function in
libckan for each function in the CKAN API. This won't work because:

- As new versions of CKAN are released with new API functions, those API
  functions will have to be added to libckan as well

- Different sites run different versions of CKAN, with different API
  functions available, and we probably want the same version of
  libckan to be able to to interact with different sites

- Some sites may have CKAN extensions installed that add custom action
  functions to the API, and these functions would not be usable with
  libckan, unless those sites also provide a custom version of
  libckan.

All in all it seems simpler and better if the user supplies the name of
the action function they want to call as a string, like:

    ckanclient.post_to_ckan_api('package_create', name='foobar')




More information about the ckan-dev mailing list