[ckan-dev] IDomainObjectNotification.notify_after_commit

Tom Mortimer-Jones tom at morty.co.uk
Mon Jan 12 08:47:14 UTC 2015


Hello Denis,

I added this method to the interface last year:

https://github.com/ckan/ckan/commit/3282b12e3f6b694693799e832fe8d4f731fa5b57

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



More information about the ckan-dev mailing list