[ckan-dev] IDomainObjectModification

Ross Jones ross at servercode.co.uk
Fri Mar 21 09:56:25 UTC 2014


Hi,

I would like to intercept model changes to model.TaskStatus, and it isn't working for me.  On further inspection it turns out that at https://github.com/ckan/ckan/blob/master/ckan/model/modification.py#L40-L56 that it will only work for for model.Package or model.Resource objects - am I reading it correctly (lack of coffee makes me not sure)?

As a use-case I’d like to be able to know when a new task_status has been created (so that I can add an extra to the resource to mark it as broken), and in future I can see a requirement for me needing to know when a user has been created, or updated, deleted etc.

Should IDomainObjectModification be extended to work with all the major objects? Would this cause a dramatic slow-down if the notify() calls were made every time a model was saved? I have a personal preference for the Django style signals (https://docs.djangoproject.com/en/dev/topics/signals/) where functions can register interest in specific signals and only receives those signals for the events and model types that the dev is interested in. I can’t see it wouldn't make much sense to re-implement this functionality in CKAN from scratch.

Any suggestions for a reasonable approach that doesn’t involve me using before_commit and trawling through the object_cache to find out if I just happen to be creating a new task_status?

Cheers

Ross
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140321/ca04f1b2/attachment-0002.html>


More information about the ckan-dev mailing list