[ckan-dev] IDomainObjectNotification.notify_after_commit

Denis Zgonjanin deniszgonjanin at gmail.com
Mon Jan 12 15:19:25 UTC 2015


Thanks Tom,

I'm using ckan master, and noticed that the actions that were triggering
notify - eg. package create, update, etc... were not also triggering
notify_after_commit(). Setting a breakpoint at
https://github.com/ckan/ckan/blob/master/ckan/model/modification.py#L92,
the code simply never executes under any conditions I've tested.

notify_after_commit is more useful for my use case, so if you have any
ideas on why it is not being fired, let me know. I'll keep poking around.

Denis

On Mon, Jan 12, 2015 at 3:47 AM, Tom Mortimer-Jones <tom at morty.co.uk> wrote:

> Hello Denis,
>
> I added this method to the interface last year:
>
> https://github.com/ckan/ckan/commit/3282b12e3f6b694693799e832fe8d4
> f731fa5b57
>
>  The plugin interface IDomainObjectNotification works fine with the
>> notify() method, but the notify_after_commit() method doesn't seem to get
>> activated anytime, for any model operation.
>>
> Because notify() is being triggered by the before_commit() hook of
> SQLAlchemy it is possible to quickly make a query and receive the old value
> of the object that has been modified. I didn't want to break anything that
> might be depending on the exiting behaviour so I added the extra method
> with is triggered by after_commit() hook. This removed the race condition
> that we were observing. It is activated in the same way notify() is, but
> listening for a different hook.
>
>> There don't seem to be any tests which test this interface
>>
> True.
>
>> Does anyone know if this actually works, and if so, under what conditions?
>>
> It was implemented to maintain backward compatibility with an plugins
> which might be using the interface already. The edge case that it addresses
> is quite niche as you have to make a subsequent query rather than using the
> object that is passed when the notify() method is called. Is it causing you
> an issue?
>
> Tom.
> _______________________________________________
> 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/20150112/ea7a2d67/attachment-0003.html>


More information about the ckan-dev mailing list