[ckan-dev] purging revisions

Haq, Salman Salman.Haq at neustar.biz
Tue Jul 24 13:22:44 UTC 2012



On 7/24/12 6:18 AM, "Sean Hammond" <sean.hammond at okfn.org> wrote:

>> Given an extension ("myextension") that introduces it's own revisioned
>> model entities, how can I ensure that the associated revisions are
>> returned by Package.all_related_revisions?
>
>I'm not sure you can do this without modifications to CKAN core,
>ckan.model.package.Package.all_related_revisions() looks specifically
>for PackageRevision, PackageTagRevision, PackageExtraRevision and
>ResourceRevisision objects, it doesn't look for your custom entities
>introduced by your extension.
>
>> The issue I'm running into is that when I delete and purge a package, I
>> receive the following errors:
>> 
>> Problem purging revision fe09a50b-3f65-4bda-a555-6ba39cf6f3f2:
>> (IntegrityError) update or delete on table "revision" violates foreign
>>key
>> constraint "myextension_group_revision_id_fkey" on table
>> "myextension_group" DETAIL: Key
>> (id)=(fe09a50b-3f65-4bda-a555-6ba39cf6f3f2) is still referenced from
>>table
>> "myextension_group". 'DELETE FROM revision WHERE revision.id = %(id)s'
>> {'id': u'fe09a50b-3f65-4bda-a555-6ba39cf6f3f2'}
>
>I think it's considered bad practice for extensions to introduce foreign
>keys against core models, as it causes problems:
>
>http://docs.ckan.org/en/latest/writing-extensions.html#libraries-available
>-to-extensions

Sean, 

Thanks for the researched reply.

What is considered a best practice for my use case?



Thanks,
Salman


>
>_______________________________________________
>ckan-dev mailing list
>ckan-dev at lists.okfn.org
>http://lists.okfn.org/mailman/listinfo/ckan-dev





More information about the ckan-dev mailing list