Merge lp://staging/~gary/launchpad/move-events-to-filters into lp://staging/launchpad/db-devel

Proposed by Gary Poster
Status: Merged
Approved by: Gary Poster
Approved revision: no longer in the source branch.
Merged at revision: 10164
Proposed branch: lp://staging/~gary/launchpad/move-events-to-filters
Merge into: lp://staging/launchpad/db-devel
Diff against target: 1278 lines (+376/-298)
23 files modified
database/sampledata/current-dev.sql (+4/-4)
database/sampledata/current.sql (+4/-4)
database/schema/comments.sql (+1/-1)
database/schema/patch-2208-37-0.sql (+12/-0)
lib/canonical/launchpad/mail/helpers.py (+1/-5)
lib/lp/bugs/browser/bugsubscriptionfilter.py (+45/-1)
lib/lp/bugs/browser/structuralsubscription.py (+4/-35)
lib/lp/bugs/browser/tests/test_bugsubscriptionfilter.py (+85/-0)
lib/lp/bugs/browser/tests/test_structuralsubscription.py (+0/-133)
lib/lp/bugs/doc/bug-change.txt (+7/-2)
lib/lp/bugs/doc/bugnotification-sending.txt (+133/-10)
lib/lp/bugs/doc/bugsubscription.txt (+15/-8)
lib/lp/bugs/doc/structural-subscriptions.txt (+0/-2)
lib/lp/bugs/interfaces/bugsubscriptionfilter.py (+8/-0)
lib/lp/bugs/interfaces/structuralsubscription.py (+6/-26)
lib/lp/bugs/model/bugsubscriptionfilter.py (+6/-0)
lib/lp/bugs/model/structuralsubscription.py (+16/-35)
lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py (+9/-0)
lib/lp/bugs/model/tests/test_bugtask.py (+3/-2)
lib/lp/bugs/tests/structural-subscription-target.txt (+10/-19)
lib/lp/bugs/tests/test_bugchanges.py (+4/-1)
lib/lp/bugs/tests/test_structuralsubscriptiontarget.py (+3/-6)
lib/lp/registry/doc/private-team-roles.txt (+0/-4)
To merge this branch: bzr merge lp://staging/~gary/launchpad/move-events-to-filters
Reviewer Review Type Date Requested Status
Gavin Panella (community) code Approve
Graham Binns (community) code Approve
Stuart Bishop (community) db Approve
Robert Collins db Pending
Review via email: mp+48069@code.staging.launchpad.net

Commit message

[r=allenap,gmb,stub][ui=none][bug=711376] move the event filter enumeration off of the structural subscription and on to the filter object.

Description of the change

Part of https://dev.launchpad.net/LEP/BetterBugSubscriptionsAndNotifications . It is a necessary step to providing the functionality described in the "Must" section of the LEP.

This branch moves the event filter enumeration off of the structural subscription, and on to the filter object. Combined with Gavin's filter work, this makes it possible to, for instance, subscribe to all bug notifications for a project or package with a "ui" tag and also subscribe to only creation/closing bug notifications with a "bugjam" tag.

"make lint" only complains about some circular dependencies that are not an issue with my changes to my knowledge.

All tests I touched pass for me. ec2 is currently running tests for this branch.

This branch is large but I'm not sure how I would have made it smaller. If you'd like to talk it over with me maybe we could come up with a way to divide it?

Thank you

Gary

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

A worry: target.addSubscription did result in a subscription that had a level of NOTHING. We never exposed that, to my knowledge, instead relying publicly on addBugSubscription, which always explicitly set a level of COMMENTS. Now, this branch creates subscriptions without filters, which means addBugSubscription has the same result, but addSubscription does not. I don't think it is an issue, but I'd like a sanity check from an expert (gmb? :-D )

Revision history for this message
Gary Poster (gary) wrote :

There's one more thing I hope will get someone's attention: the XXX I added. I intend to remove it after discussion and resolution in this review.

Here's the concern. The filter class (lp.bugs.model.bugsubscriptionfilter.BugSubscriptionFilter) has an explicit "delete" method that will delete all of its subobjects (that is, records in the database in a many to one relationship with the filter class). However, the structural subscriptions do not have any similar code for the filters, which are themselves many to one with the structural subscriptions. Why? Is the delete method in BugSubscriptionFilter overkill because we have cascading delete in the database, or do I need to do something similar to the delete method on structural subscriptions? This seems like an elementary question for LP development, but not something I've encountered yet.

Thanks.

Revision history for this message
Stuart Bishop (stub) wrote :

Fine. patch-2208-37-0.sql

review: Approve (db)
Revision history for this message
Graham Binns (gmb) wrote :

> A worry: target.addSubscription did result in a subscription that had a level
> of NOTHING. We never exposed that, to my knowledge, instead relying publicly
> on addBugSubscription, which always explicitly set a level of COMMENTS. Now,
> this branch creates subscriptions without filters, which means
> addBugSubscription has the same result, but addSubscription does not. I don't
> think it is an issue, but I'd like a sanity check from an expert (gmb? :-D )

I don't think that's going to be an issue (and I'd like to think that tests will blow up if it is).

Revision history for this message
Graham Binns (gmb) wrote :

> There's one more thing I hope will get someone's attention: the XXX I added.
> I intend to remove it after discussion and resolution in this review.
>
> Here's the concern. The filter class
> (lp.bugs.model.bugsubscriptionfilter.BugSubscriptionFilter) has an explicit
> "delete" method that will delete all of its subobjects (that is, records in
> the database in a many to one relationship with the filter class). However,
> the structural subscriptions do not have any similar code for the filters,
> which are themselves many to one with the structural subscriptions. Why? Is
> the delete method in BugSubscriptionFilter overkill because we have cascading
> delete in the database, or do I need to do something similar to the delete
> method on structural subscriptions? This seems like an elementary question
> for LP development, but not something I've encountered yet.

I don't know the answer to this, I'm afraid. I don't see anything in the DB that suggests we have a cascading delete set up in the database, and IIRC you'll get an OOPS if you try to delete something that has other DB rows hanging off it. My best suggestion would be to write a test for this and see whether smoke comes out.

Revision history for this message
Graham Binns (gmb) wrote :

Hi Gary,

So, I'm broadly-speaking +1 on this branch landing (note that I'm on a fairly narrow bandwidth at the moment, so I've gone straight for understanding the code and not worried too much about formatting issues). However, I don't feel that I have enough knowledge about the way that filters work at the moment to offer a definite r=me. I'd suggest you ask Gavin to cast a weather eye over it too, since the filters were at least in part his work.

Anyway, approval from me. Nice work; I don't think I can see a way to break it up without causing some heartache, so don't worry about the branch size.

review: Approve (code)
Revision history for this message
Gavin Panella (allenap) wrote :

This is really cool :) I have an answer for your specific question in
[2], and one other trivial comment.

[1]

+ LaunchpadEditFormView.setUpFields(self)

Consider using super() here.

[2]

+ # XXX Delete all associated filters.
         store = Store.of(subscription_to_remove)
         store.remove(subscription_to_remove)

Mucking about in bin/iharness shows that the filters need to be
explicitly deleted too.

> Is the delete method in BugSubscriptionFilter overkill because we
> have cascading delete in the database, or do I need to do something
> similar to the delete method on structural subscriptions?

Yes :) I never thought to put it in before.

I talked briefly with Aaron about this before. There isn't a clear
story for deleting stuff in Launchpad. We have destroySelf() in some
places, a hang-over from SQLObject, and delete() in other places, and
many places do store.remove(thing) without thinking about it.

It might work to have a __storm_remove__ hook so that things like
BugSubscriptionFilter can take responsibility of its
dependencies. Then we would always use store.remove(). However, that
doesn't work from view code which must not speak of the store. I
suspect a mishmash will rule.

review: Approve (code)
Revision history for this message
Gary Poster (gary) wrote :

Thank you for the reviews!

I have changed to use super (I was too lazy at the time to verify that the base class was new-style; in the LP code base, I suppose I should have assumed yes).

In regards to the XXX, I want to do this in a separate branch, since this one was so gigantic. It also is a bug outside of the code I added in this branch, which I'm using to further rationalize the decision. :-) I created bug 711362 and will be beginning a branch for it (with tests as Graham suggested and a delete method as Gavin suggested) within the hour.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: