Comment 7 for bug 720147

Revision history for this message
Gavin Panella (allenap) wrote : Re: [Bug 720147] Re: Subscription to New or Incomplete bugs is allowing just-filed bugs of all statuses through

On 28 April 2011 12:17, Graham Binns <email address hidden> wrote:
> On 28 April 2011 09:49, Gavin Panella <email address hidden> wrote:
[...]
>> The call to context.createBug(...) fires an ObjectCreatedEvent, which
>> is probably where notifications to subscribers are sent... *before*
>> the status is updated.
>
> It could be this or it could be the transitionToStatus() call that's
> doing the notification.

I'm reasonably sure that transitionToStatus() does not notify().

Instead I think a view takes care of firing an ObjectModifiedEvent
(once all changes have been applied), and the web service machinery
does the same for API calls over the wire.

[...]
>> Now, status can be set on the CreateBugParams object that is passed
>> into createBug(), but not importance for example, so a general fix is
>> not possible down that road without adding more to CreateBugParams.
>>
>> A general fix might involve delaying the notification of the
>> ObjectCreatedEvent within createBug(). createBugWithoutTarget() is an
>> example of how a similar problem has been solved in the past.
>
> Right. I'm broadly more in favour of fixing CreateBugParams to accept
> more options than futzing around with when notify() happens and which
> method's responsible for it.

I think it might be a bad idea to bypass transitionToStatus() because
it does a *lot* more than set the bug's status. It's probably true of
all the transitionTo*() methods.

The very end of BugSet.createBug() is:

        # Tell everyone.
        notify(event)

        # Calculate the bug's initial heat.
        bug.updateHeat()

        return bug

The call to updateHeat() could probably come before notify():

        # Calculate the bug's initial heat.
        bug.updateHeat()

        # Tell everyone.
        notify(event)

        return bug

Then it's only a short hop to having two functions:

    def createBug(self, bug_params):
        bug, event = self.createBugAndEvent(bug_params)
        notify(event)
        return bug

    def createBugAndEvent(self, bug_params):
        ...
        return bug, event

FileBugViewBase.submit_bug_action can call createBugAndEvent(), muck
around with the bug's state, then notify().