launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06299
[Merge] lp:~wgrant/launchpad/bug-929241 into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/bug-929241 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #929241 in Launchpad itself: "ProductPackagesPortletView calculates suggestions when it knows it won't show them"
https://bugs.launchpad.net/launchpad/+bug/929241
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-929241/+merge/92178
ProductPackagesPortletView is always rendered by Product:+index, leaving it up to the portlet to decide whether to show a form of suggestions, show a list of packages, or hide itself entirely. The first is an uncommon, expensive case: it performs an FTI query on DistributionSourcePackageCache to make suggestions. But LaunchpadForm.initialize() unconditionally calls setUpFields(), which precalculates the suggestions.
This branch overrides initialize() so the suggestions are only calculated when the form is going to be used.
--
https://code.launchpad.net/~wgrant/launchpad/bug-929241/+merge/92178
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-929241 into lp:launchpad.
=== modified file 'lib/lp/registry/browser/product.py'
--- lib/lp/registry/browser/product.py 2012-02-01 15:26:32 +0000
+++ lib/lp/registry/browser/product.py 2012-02-09 01:29:24 +0000
@@ -1301,6 +1301,14 @@
"""See `LaunchpadFormView`."""
return {self.package_field_name: self.other_package}
+ def initialize(self):
+ # The template only shows the form if the portlet is shown and
+ # there aren't any linked sourcepackages. If either of those
+ # conditions fails, there's no point setting up the widgets
+ # (with the expensive FTI query that entails).
+ if self.can_show_portlet and not self.sourcepackages:
+ super(ProductPackagesPortletView, self).initialize()
+
def setUpFields(self):
"""See `LaunchpadFormView`."""
super(ProductPackagesPortletView, self).setUpFields()