Merge lp:~linaro-infrastructure/launchpad/notify-workitems-changes into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Aaron Bentley on 2012-03-21 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 14997 |
| Proposed branch: | lp:~linaro-infrastructure/launchpad/notify-workitems-changes |
| Merge into: | lp:launchpad |
| Diff against target: |
261 lines (+146/-4) 3 files modified
lib/lp/blueprints/browser/specification.py (+19/-0) lib/lp/blueprints/mail/notifications.py (+12/-1) lib/lp/blueprints/model/tests/test_specification.py (+115/-3) |
| To merge this branch: | bzr merge lp:~linaro-infrastructure/launchpad/notify-workitems-changes |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Aaron Bentley (community) | 2012-03-19 | Approve on 2012-03-21 | |
|
Review via email:
|
|||
Commit Message
[r=abentley] Add email notifications for Work Item changes and fix the +workitems page.
Description of the Change
This branch adds email notifications for Work Items changes on Blueprints. To get the same format users are used to from the Whiteboard we use the same mechanisms to send a diff of the workitems_text property.
I've had to add an extra transaction.
| Guilherme Salgado (salgado) wrote : | # |
| Mattias Backman (mabac) wrote : | # |
On Mon, Mar 19, 2012 at 7:22 PM, Guilherme Salgado
<email address hidden> wrote:
> Unfortunately, I don't think this actually fixes the bug. AIUI, the email notifications were not being sent because nothing emits an ObjectModifiedE
That's the mystery here. ;) Since I started writing the tests, I ended
up with a call to notify() in updateWorkItems(). Later when I tried to
run the test Launchpad locally I got two notifications for each change
so I removed my call to notify(). Something else is actually seeing
the change on a Specification property and fires the notification in
the running system.
The reason for not getting emails seems to be that nothing in
notify_
workitems delta.
The automagical notify does not happen when running the tests though,
so I followed the example in
lp.bugs.
a bugtask property and then fires it's own notification.
> --
> https:/
> Your team Linaro Infrastructure is subscribed to branch lp:~linaro-infrastructure/launchpad/notify-workitems-changes.
| Guilherme Salgado (salgado) wrote : | # |
Oh, so I was wrong all along, thinking the event was what we were missing, and you didn't tell me? ;)
So, now that you pointed me in the right direction I can see where this is coming from... The event is fired by lazr.restful whenever someone calls a remote operation (like updateStatus(), which is exported as a write operation), so that's why you don't get the event when you call updateStatus() directly. I suggest you add a comment to the test explaining why you need to fire the event yourself and that in production this is not needed. However, if someone edits the workitems using the +workitems page, no notification will be sent because that code doesn't call updateStatus() via lazr.restful and so no event is fired. We might need to have that page itself fire an ObjectModifiedE
Now, it looks like the work item changes are not always flushed to the DB when notify_
(this is within notify_
(Pdb) p spec.workitems_text
''
(Pdb) !from lp.services.
(Pdb) p flush_database_
None
(Pdb) p spec.workitems_text
u'Work items:\nfoo: TODO\nbar: DONE'
I wouldn't expect this tot happen because spec.workitems_text will do a DB query and before executing that storm will flush the updates to the DB. As you've found out, calling transaction.
| Guilherme Salgado (salgado) wrote : | # |
<lifeless> salgado: IIRC the only reason a select wouldn't see new objects is if both the select and the store.add for the objects *both* happen within a block_implicit_
In our case the select runs inside a block_implicit_
| Guilherme Salgado (salgado) wrote : | # |
<lifeless> you might want to figure out why it has that decorator
<lifeless> this smells to me of some bug patched over
<lifeless> if it was e.g. a truism that all event handlers must not permit implicit flushes, we'd have glued it into the event subscription code to avoid the repetition
<lifeless> salgado: I would look in annotate for the commit adding the decorator and see what it was part of; look at the MP too probably; and definitely try removing the decorator and seeing what happens
| Mattias Backman (mabac) wrote : | # |
Removing @block_
I added code to send notifications from the +workitems page and in the process fixed it so that is also saves the changes.
| Aaron Bentley (abentley) wrote : | # |
LOC increased acceptable because this was part of work that had decreased LOC.

Unfortunately, I don't think this actually fixes the bug. AIUI, the email notifications were not being sent because nothing emits an ObjectModifiedE vent(spec) after the spec's work items are changed (which is expected because there are no changes to the spec itself, only to things related to it) and your changes doesn't seem to cause that event to be fired either. You have the notify( ObjectModifiedE vent(.. .)) call in your tests, but in production that event is not going to be fired anywhere since the Specification object itself is not changed. My suggestion was to have updateWorkItems() fire the event, in the same way that Product. _setLicenses( ) (which is very similar to our case in that it changes objects related to the Product but not the Product itself) does.