← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~lifeless/launchpad/bug-743970 into lp:launchpad

 

Robert Collins has proposed merging lp:~lifeless/launchpad/bug-743970 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #743970 in Launchpad itself: "ProductSet:+all timeouts"
  https://bugs.launchpad.net/launchpad/+bug/743970

For more details, see:
https://code.launchpad.net/~lifeless/launchpad/bug-743970/+merge/55033

/projects/+all was loading all the info to render the details of a project, but not using them. This fixes that and also eager loads the info needed to render the owner links.
-- 
https://code.launchpad.net/~lifeless/launchpad/bug-743970/+merge/55033
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/launchpad/bug-743970 into lp:launchpad.
=== modified file 'lib/lp/registry/browser/configure.zcml'
--- lib/lp/registry/browser/configure.zcml	2011-01-24 20:53:10 +0000
+++ lib/lp/registry/browser/configure.zcml	2011-03-28 03:10:57 +0000
@@ -1443,9 +1443,6 @@
         <browser:page
             name="+listing-for-review"
             template="../templates/product-listing-for-review.pt"/>
-        <browser:page
-            name="+listing-detailed"
-            template="../templates/product-listing-detailed.pt"/>
 
         <!-- Products Portlets -->
 
@@ -1482,6 +1479,12 @@
         name="+packages"
         facet="overview"
         template="../templates/product-packages.pt"/>
+    <browser:page
+        for="lp.registry.interfaces.product.IProduct"
+        permission="zope.Public"
+        class="canonical.launchpad.webapp.LaunchpadView"
+        name="+listing-detailed"
+        template="../templates/product-listing-detailed.pt"/>
     <browser:renamed-page
         name="+distributions"
         for="lp.registry.interfaces.product.IProduct"

=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py	2011-03-24 20:48:35 +0000
+++ lib/lp/registry/model/product.py	2011-03-28 03:10:57 +0000
@@ -1361,10 +1361,14 @@
 
     @property
     def all_active(self):
-        results = Product.selectBy(
-            active=True, orderBy="-Product.datecreated")
-        # The main product listings include owner, so we prejoin it.
-        return results.prejoin(["_owner"])
+        result = IStore(Product).find(Product, Product.active
+            ).order_by(Desc(Product.datecreated))
+        def eager_load(rows):
+            owner_ids = set(map(operator.attrgetter('_ownerID'), rows))
+            # +detailed-listing renders the person with team branding.
+            list(getUtility(IPersonSet).getPrecachedPersonsFromIDs(
+                owner_ids, need_validity=True, need_icon=True))
+        return DecoratedResultSet(result, pre_iter_hook=eager_load)
 
     def get(self, productid):
         """See `IProductSet`."""