[ckan-dev] How to access an array in extra-fields ?
David Raznick
kindly at gmail.com
Thu Apr 28 15:44:09 UTC 2011
On Thu, Apr 28, 2011 at 4:14 PM, William Waites <ww at styx.org> wrote:
> * [2011-04-28 16:03:41 +0100] David Raznick <kindly at gmail.com> écrit:
>
> ] I am doing a rewrite of that code as we speak. I am not too sure how to
> fix
> ] it though. The wui expects a string and in the api it treats it as json.
> ] So saving in the form is bound to destroy up the json.
>
> Judging from the output it is getting saved as a repr'd version of the
> python - should it not alt least be using json.dumps?
>
It should be getting a json dumps only if its *not* a plain string. It is
stored as a json but on return to the wui it gets converted to the repred
version.
I think the expectation is to get a plain string displayed and not a quoted
one in the wui in the case of a plain string being input.
For reading from the API, you *could* try to json.loads it and if that
> fails put the string. But mind that this is a backwards incompatible
> change - there is code out there (mine and others') that expects the
> value to be a string.
>
> -w
>
>
I do not really want to change the api. I think changing the front end to
know the difference between a string and a possible json object is the only
way, even though thats not great. This will mean that if a user tries to
put in anything that looks like a json then it will be interpreted as that
even when they meant it as a string.
The best option is to have another field to say if it is a json or a string
but I imagine that will make the extras interface even uglier.
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20110428/a337ecd8/attachment-0001.html>
More information about the ckan-dev
mailing list