[ckan-dev] Rollback when resource creation fails

Alex Gartner alexandru.gartner+ckan at gmail.com
Wed Apr 6 13:53:35 UTC 2016


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 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.

Best,
Alex

On Wed, Apr 6, 2016 at 4:27 PM, Martin Burchell <martinb-ckan at aptivate.org>
wrote:

> On 06/04/16 13:16, Hendrik Bunke wrote:
>
>> You can purge the trash via API, see here:
>>
>> http://stackoverflow.com/questions/30153596/delete-and-purge-a-package-in-ckan-using-api
>>
>
> Thanks. I'll take a look but it may be that we want something a bit more
> elegant than that.
>
> Will you publish the plugin? We'd be quite interested in that :-)
>>
>
> It's specific to a particular customer's requirements but the code is open
> source: <https://github.com/aptivate/ckanext-mapactionimporter>
>
> <https://github.com/ckan/ckanext-datapackager> is more generic and does
> something similar to what we are trying to achieve.
>
>
> Best regards,
>
>
> --
> Martin Burchell
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20160406/3c394c21/attachment-0003.html>


More information about the ckan-dev mailing list