[ckan-dev] Rollback when resource creation fails

Alex Gartner alexandru.gartner+ckan at gmail.com
Wed Apr 6 18:11:54 UTC 2016


Yes, you're right, by default it does require users to be sysadmins.
But you can easily override the auth function for dataset_purge() in your
own extension to have the same authorization logic as package_delete().

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

> 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
>
> _______________________________________________
> 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/6001d7af/attachment-0003.html>


More information about the ckan-dev mailing list