[ckan-dev] Rollback when resource creation fails

Martin Burchell martinb-ckan at aptivate.org
Wed Apr 6 16:50:43 UTC 2016


On 06/04/16 14:53, Alex Gartner wrote:
> You can directly remove a dataset from the database by using
> dataset_purge()
> <https://github.com/ckan/ckan/blob/ckan-2.5.2/ckan/logic/action/delete.py#L83>(
> which I think exists since CKAN 2.5, but could be backported to older CKAN
> versions if needed ).

I think that would require all our users to be sysadmins, wouldn't it?

> I think you could also use the "resources" parameter in the
> package_create() API action to create some resources in the same API call
> that creates the package. Unfortunately, I seem to remember a discussion on
> this forum about this only working with "url"-type resources and not with
> "uploaded" resource.  Would love to know if there's actually a way of
> creating dataset and "uploaded" resource at the same time.

That would be ideal. I think I also saw that discussion, or a similar one.

For now we have settled on appending a unique identifier to the dataset 
name until after the resources have been created. That way we don't get 
the URL clash if the user uploads a dataset with modified resources. A 
sysadmin can periodically purge failed datasets.

-- 
Martin Burchell




More information about the ckan-dev mailing list