[ckan-discuss] Difficulty deleting resources
Brian Lee Yung Rowe
rowe at muxspace.com
Fri Nov 15 17:43:17 UTC 2013
Adria,
Thanks so much for the guidance. I looked at the ckanapi project, and it doesn't seem to include the file upload capabilities of ckanclient. Is the idea that ckanapi will replace ckanclient or should I consider them to serve different purposes?
Many Thanks,
Brian
On Nov 15, 2013, at 5:47 AM, Adrià Mercader <adria.mercader at okfn.org> wrote:
> Hi Brian,
>
> To delete a resource you need to provide the internal id on the
> resource_delete call, eg:
>
> curl -d '{"id": "e8d5339e-1d00-4ba9-b8e5-8ffa1a3d054f"}' -H
> 'Authorization: xxxx' http://localhost:5000/api/action/resource_delete
>
>
> BTW, ckanapi will be probably easy to use with the new API than ckanclient:
>
> https://github.com/open-data/ckanapi
>
>
> Hope this helps,
>
> Adrià
>
>
> On 9 November 2013 22:51, Brian Lee Yung Rowe <rowe at muxspace.com> wrote:
>> Hello,
>>
>> I am having a trouble deleting resources via the CKAN API. Really what I want to do is update a JSON resource with a newer version of the JSON. I've tried a few different approaches, none of which have succeeded. Any help is greatly appreciated.
>>
>> Method 1: ckanclient
>> client = CkanClient('http://odessa.zatonovo.com/api/3', apikey)
>> client.action('resource_delete', id='cw_articles-2013-11-04.json')
>>
>> CkanApiNotAuthorizedError Traceback (most recent call last)
>>
>> 538 self.reset()
>> 539 url = self.get_action_location(action_name)
>> --> 540 self.open_action_url(url, kwargs)
>> 541 return self.last_result
>>
>> Note that the resource_show action works fine:
>> client.action('resource_show', id='cw_articles-2013-11-04.json')
>> {u'cache_last_updated': None,
>> u'cache_url': None,
>> u'created': u'2013-11-06T02:04:22.625862',
>> u'description': u'',
>> u'format': u'JSON',
>> u'hash': u'',
>> ...
>>
>>
>> Method 2: curl
>> curl -X POST -d '{ "state":"deleted", "id":"cw_articles-2013-11-04.json"}' -H "Authorization:apikey" "http://odessa.zatonovo.com/api/3/action/resource_delete"
>>
>> This results in an Internal Server Error, the source of which is a SQL Alchemy assertion error.
>>
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] File '/usr/lib/ckan/default/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py', line 475 in execute
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] uow
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] File '/usr/lib/ckan/default/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py', line 45 in save_obj
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] uowtransaction)
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] File '/usr/lib/ckan/default/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py', line 149 in _organize_states_for_save
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] mapper.dispatch.before_update(mapper, connection, state)
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] File '/usr/lib/ckan/default/lib/python2.7/site-packages/sqlalchemy/event.py', line 291 in __call__
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] fn(*args, **kw)
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] File '/usr/lib/ckan/default/lib/python2.7/site-packages/sqlalchemy/orm/events.py', line 363 in wrap
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] return wrapped_fn(*arg, **kw)
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] File '/usr/lib/ckan/default/lib/python2.7/site-packages/vdm/sqlalchemy/base.py', line 606 in before_update
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] self.set_revision(instance)
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] File '/usr/lib/ckan/default/lib/python2.7/site-packages/vdm/sqlalchemy/base.py', line 532 in set_revision
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] assert current_rev, 'No revision is currently set for this Session'
>> [Sat Nov 09 22:06:45 2013] [error] [client 64.131.129.125] AssertionError: No revision is currently set for this Session
>>
>>
>> Platform info: Ubuntu 12.04.2 LTS
>>
>> $ apt-cache show python-ckan
>> Package: python-ckan
>> Status: install ok installed
>> Version: 2.0.2-1
>>
>> Many Thanks,
>> Brian
>> _______________________________________________
>> ckan-discuss mailing list
>> ckan-discuss at lists.okfn.org
>> http://lists.okfn.org/mailman/listinfo/ckan-discuss
>> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-discuss
More information about the ckan-discuss
mailing list