jdriscoll/django-imagekit — pull request #221 by matthewwithanm (2013-05-25 05:24:48+00:00)
Title: Source Signal Cleanup

This is in reference to #214. Mainly, it does two things:

1. Combines the "source_created" and "source_changed" signals into a single signal ("source_saved")
2. Fixes @saulshanabrook's issue where the signal was dispatched when there was no source.
3. Removes the "source_deleted" signal.

@lettertwo @saulshanabrook @bryanveloso I'd like to get you guys to review this before I merge, if you wouldn't mind.

My reasoning is as follows:

1. source_created and source_changed didn't really have clear definitions. In truth, their names and separation betray their origins as model receivers in earlier versions (the model is created/changed, not the source). The "source group" abstraction helped us get away from thinking about things exclusively in
terms of models, but these remained as an artifact. The new signal is dispatched whenever a spec gets a new source.
2. Self explanatory.
3. The point of the source_deleted signal was to give the user a chance to delete the now-unused spec file they had generated earlier. (Note, though, that it wouldn't be enough to ensure that you have no "extra" cache images lying around, as there are other things—e.g. changing processors—that would result in a new image being generated but which we have no way of detecting.) However, it was poorly named (the model was deleted, not the source—another artifact of the origin as a model receiver) and it wasn't dispatched for the "old" source when a model's image field was changed (which would require us to store the source image on model initialization—not just the hash). I still it's desirable to have this *kind* of signal but, given the imperfection of source_deleted and the fact that it isn't being used by any of the built-in strategies, I think it's best to jettison it for 3.0 instead of being stuck with it.

So before I merge this, I'd like to know:

1. Do you agree with the combining of source_created and source_changed?
2. Do you like the "on_source_saved" name? (Consider what you think the signal/callback outlined in number 3 above would be called and whether the two make sense together.)

Sorry to hold up 3.0 again, but this is an API thing so I want to have it nailed down. After this is resolved, we should tag and push to PyPI. (It's really long ovedue.)

Thanks!