launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06132
[Merge] lp:~stevenk/launchpad/kill-bugtask-launchbag-with-fire into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/kill-bugtask-launchbag-with-fire into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/kill-bugtask-launchbag-with-fire/+merge/89357
ILaunchBag needs to die. This branch brings that one step closer to reality by removing its use from the BugTask views.
--
https://code.launchpad.net/~stevenk/launchpad/kill-bugtask-launchbag-with-fire/+merge/89357
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/kill-bugtask-launchbag-with-fire into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py 2012-01-17 14:14:49 +0000
+++ lib/lp/bugs/browser/bugtask.py 2012-01-19 22:56:26 +0000
@@ -281,7 +281,6 @@
)
from lp.services.webapp.batching import TableBatchNavigator
from lp.services.webapp.breadcrumb import Breadcrumb
-from lp.services.webapp.interfaces import ILaunchBag
from lp.services.webapp.menu import structured
@@ -651,7 +650,7 @@
# Make sure we always have the current bugtask.
if not IBugTask.providedBy(context):
- self.context = getUtility(ILaunchBag).bugtask
+ self.context = context.default_bugtask
else:
self.context = context
list(getUtility(IPersonSet).getPrecachedPersonsFromIDs(
@@ -1216,9 +1215,9 @@
return '_'.join(parts)
-def get_assignee_vocabulary_info(context):
+def get_assignee_vocabulary_info(context, user):
"""The vocabulary of bug task assignees the current user can set."""
- if context.userCanSetAnyAssignee(getUtility(ILaunchBag).user):
+ if context.userCanSetAnyAssignee(user):
vocab_name = 'ValidAssignee'
else:
vocab_name = 'AllUserTeamsParticipation'
@@ -1520,7 +1519,8 @@
self.form_fields.get('assignee', False)):
# Make the assignee field editable
self.form_fields = self.form_fields.omit('assignee')
- vocabulary, ignored = get_assignee_vocabulary_info(self.context)
+ vocabulary, ignored = get_assignee_vocabulary_info(
+ self.context, self.user)
self.form_fields += formlib.form.Fields(PersonChoice(
__name__='assignee', title=_('Assigned to'), required=False,
vocabulary=vocabulary, readonly=False))
@@ -1658,8 +1658,7 @@
if comment_on_change:
bugtask.bug.newMessage(
- owner=getUtility(ILaunchBag).user,
- subject=bugtask.bug.followup_subject(),
+ owner=self.user, subject=bugtask.bug.followup_subject(),
content=comment_on_change)
new_status = new_values.pop("status", missing)
@@ -1817,8 +1816,6 @@
self.request.response.setHeader('Content-type',
'application/json')
return dumps(None)
- launchbag = getUtility(ILaunchBag)
- launchbag.add(bug.default_bugtask)
# If we are deleting the current highlighted bugtask via ajax,
# we must force a redirect to the new default bugtask to ensure
# all URLs and other client cache content is correctly refreshed.
@@ -2291,8 +2288,8 @@
# XXX sinzui 2009-05-29 bug=381672: Extract the BugTaskListingItem
# rules to a mixin so that MilestoneView and others can use it.
self.request = request
+ self.user = request.user
self.target_context = target_context
- self.user = getUtility(ILaunchBag).user
self.field_visibility_defaults = {
'show_datecreated': False,
'show_assignee': False,
@@ -3475,9 +3472,8 @@
def latestBugTasks(self, quantity=5):
"""Return <quantity> latest bugs reported against this target."""
- params = BugTaskSearchParams(orderby="-datecreated",
- omit_dupes=True,
- user=getUtility(ILaunchBag).user)
+ params = BugTaskSearchParams(
+ orderby="-datecreated", omit_dupes=True, user=self.user)
tasklist = self.context.searchTasks(params)
return tasklist[:quantity]
@@ -3765,11 +3761,8 @@
@property
def current_bugtask(self):
- """Return the current `IBugTask`.
-
- 'current' is determined by simply looking in the ILaunchBag utility.
- """
- return getUtility(ILaunchBag).bugtask
+ """Return the current `IBugTask`."""
+ return self.context.default_bugtask
def displayAlsoAffectsLinks(self):
"""Return True if the Also Affects links should be displayed."""
@@ -3942,8 +3935,7 @@
delete_link = canonical_url(self.context, view_name='+delete')
can_edit = check_permission('launchpad.Edit', self.context)
bugtask_id = self.context.id
- launchbag = getUtility(ILaunchBag)
- is_primary = self.context.id == launchbag.bugtask.id
+ is_primary = self.context.id == self.context.default_bugtask.id
self.data = dict(
# Looking at many_bugtasks is an important optimization. With
# 150+ bugtasks, it can save three or four seconds of rendering
@@ -4153,7 +4145,7 @@
def bugtask_config(self):
"""Configuration for the bugtask JS widgets on the row."""
assignee_vocabulary, assignee_vocabulary_filters = (
- get_assignee_vocabulary_info(self.context))
+ get_assignee_vocabulary_info(self.context, self.user))
# If we have no filters or just the ALL filter, then no filtering
# support is required.
filter_details = []
@@ -4365,8 +4357,7 @@
comment = data.get('comment', None)
if comment is not None:
self.context.bug.newMessage(
- owner=getUtility(ILaunchBag).user,
- subject=self.context.bug.followup_subject(),
+ owner=self.user, subject=self.context.bug.followup_subject(),
content=comment)
@property