-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SignaledDataset
_on_delete signal sent before actual deletion
#234
Comments
Thanks @mrvisscher This behaviour is intentional, but I understand that it might not be obivous. The point here is that calling after then actual deletion would mean that consumers no longer have access to the object which was deleted, so they can't examine its attributes and make whatever changes they need. @jsvgoncalves Maybe it would make more sense to call this |
The three options are: i. change signal name, which implies changing downstream code that already connects to this code brightway2-data/bw2data/signals.py Line 24 in f9f3663
While I understand the name might can be slightly misleading at first, I would have a slight preference for iii., as the two other options are a breaking change to the existing API and cascade downstream to clients of the API. |
Fair enough. It would be very useful to have an after_delete signal at the very least. So our views can update with the new model change, when it has actually changed. |
That makes sense to me and a good argument in favour of:
plus adding a "new signal" that's consistent with the behaviour of |
In the
SignaledDataset
classbrightway2-data/bw2data/signals.py
Lines 243 to 259 in f9f3663
The save signal is sent after calling
save
on the superclass. However, this is not the case for the delete signal. Which is sent before the dataset is actually deleted. Meaning that connected code that expects the dataset to not be there anymore fails.It makes most sense to me that the
delete
signal is sent after deletion, so connected views can adjust to the new model accordingly. In any case the implementation of thesave
anddelete
signals is not consistent right now. With the first being send before model mutation and the latter being send after.The text was updated successfully, but these errors were encountered: