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

Daniel Graziotin dgraziotin at task3.cc
Wed Apr 3 07:56:11 UTC 2013


Hi Dave,
> -----Original Message-----
> From: ckan-dev-bounces at lists.okfn.org [mailto:ckan-dev-
> bounces at lists.okfn.org] On Behalf Of David Read
> Sent: martedì 2 aprile 2013 18.24
> To: CKAN Development Discussions
> Subject: Re: [ckan-dev] Confused on response['success'] and HTTP status
> codes with empty results
> 
> I agree that there is scope for both Sean's general purpose function, and
> Daniel's more pythonic functions. 
> [..]
> However I would advise against anything but a thin client. It should abstract
> away the HTTP-isms only and not try to 'fix' CKAN APIs. In the example for
> resource_search, you:
> * repeat the documentation - breaks the DRY principal

You are right.  To be honest, the CKAN documentation is repeated because I wanted to try some ignorant-level metaprogramming (see https://gist.github.com/dgraziotin/5228154).
The docs, the function definitions, and the initial unittests were automatically generated from CKAN source code.
Regarding the docs, I realize it would be better to have as a template something like
---
def action_name(client=client.Client, arg1, arg2, ..):
"""
1-line short description of the function
Link to corresponding CKAN action doc
Tell what client arg is
Tell if there are differences in libckan params, (e.g., some CKAN parameters are in the form <name.name>, while Python needs <name_name>)
Tell what exceptions are raised
"""
---

> * have a sanitize_params method which suggests the params need
> 'sanitizing'. This appears to remove blank keys and other magic which
> appears to be your own preferences.
> 
> If there are niggles with the API then I'd suggest you improve them at
> source, rather than write custom 'fixes' in one particular client.
> 
> Dave

Sorry if my broken English suggested this. Whit "sanitize_params" and my previous e-mail, I did not want to mean "CKAN parameters are broken".
The parameters will be "sanitized" at the client side from an API user input perspective. Not from a "CKAN is broken" perspective. 
If the function name really suggests what you wrote, please suggest a better name!
The function does nothing more than what you wrote, at the moment. It will improve in the future.

--Daniel Graziotin





More information about the ckan-dev mailing list