[ckan-dev] package_update throws error when adding extra field

Kirstein, Fabian fabian.kirstein at fokus.fraunhofer.de
Thu Jan 31 13:53:34 UTC 2013


I'm developing a custom controller, which is using the CKAN Action-API to manipulate datasets.
First I fetch the dataset with

dataset = get_action('package_show')(context, {'id': id})

then I add something to the extras field:

dataset['extras'].append({'value': 'test', 'key': 'new'})

Finally I try to save it with:

result  =  get_action('package_update')(context, dataset)

Unfortunately I receive an error:
IndexError: list index out of range
It seems that the unflatten method has a problem with my new extra field.

Thanks a lot.



Extract from the traceback:

File '/home/fki/pyenv/src/ckanext-ocean/ocean/rate.py', line 68 in new_comment
  get_action('package_update')(context, dataset)
File '/home/fki/pyenv/src/ckan/ckan/logic/action/update.py', line 253 in package_update
  data, errors = _validate(data_dict, schema, context)
File '/home/fki/pyenv/src/ckan/ckan/lib/navl/dictization_functions.py', line 237 in validate
  converted_data = unflatten(converted_data)
File '/home/fki/pyenv/src/ckan/ckan/lib/navl/dictization_functions.py', line 394 in unflatten
  current_pos = current_pos[key]
IndexError: list index out of range
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20130131/b4cc3777/attachment.html>


More information about the ckan-dev mailing list