← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wallyworld/launchpad/test-fix-rev-16106 into lp:launchpad

 

Ian Booth has proposed merging lp:~wallyworld/launchpad/test-fix-rev-16106 into lp:launchpad.

Commit message:
Rework series releases caching to fix test failures

Requested reviews:
  Ian Booth (wallyworld)

For more details, see:
https://code.launchpad.net/~wallyworld/launchpad/test-fix-rev-16106/+merge/128369

Test fix for rev 16106
Rework caching of product series releases property.
-- 
https://code.launchpad.net/~wallyworld/launchpad/test-fix-rev-16106/+merge/128369
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'lib/lp/registry/browser/product.py'
--- lib/lp/registry/browser/product.py	2012-10-06 13:55:24 +0000
+++ lib/lp/registry/browser/product.py	2012-10-06 23:47:23 +0000
@@ -922,7 +922,7 @@
         for series in self.context.series:
             if series.status == SeriesStatus.OBSOLETE:
                 continue
-            for release in series.releases:
+            for release in series.getCachedReleases():
                 if len(list(release.files)) > 0:
                     return True
         return False

=== modified file 'lib/lp/registry/interfaces/productseries.py'
--- lib/lp/registry/interfaces/productseries.py	2012-10-05 05:34:13 +0000
+++ lib/lp/registry/interfaces/productseries.py	2012-10-06 23:47:23 +0000
@@ -261,6 +261,11 @@
             "A Bazaar branch to commit translation snapshots to.  "
             "Leave blank to disable."))
 
+    def getCachedReleases():
+        """Gets a cached copy of this series' releases.
+
+        Returns None if there is no release."""
+
     def getLatestRelease():
         """Gets the most recent release in the series.
 

=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py	2012-10-06 08:02:31 +0000
+++ lib/lp/registry/model/product.py	2012-10-06 23:47:23 +0000
@@ -1613,8 +1613,9 @@
             ProductSeries,
             ProductSeries.productID.is_in(product_ids)):
             series_cache = get_property_cache(series)
-            if need_releases and not safe_hasattr(series_cache, 'releases'):
-                series_cache.releases = []
+            if (need_releases and
+                not safe_hasattr(series_cache, '_cached_releases')):
+                series_cache._cached_releases = []
 
             series_caches[series.id] = series_cache
             cache = caches[series.productID]
@@ -1630,7 +1631,7 @@
                     release_cache.files = []
                 all_releases.append(release)
                 series_cache = series_caches[milestone.productseries.id]
-                series_cache.releases.append(release)
+                series_cache._cached_releases.append(release)
 
             prs = getUtility(IProductReleaseSet)
             files = prs.getFilesForReleases(all_releases)

=== modified file 'lib/lp/registry/model/productrelease.py'
--- lib/lp/registry/model/productrelease.py	2012-10-05 03:00:21 +0000
+++ lib/lp/registry/model/productrelease.py	2012-10-06 23:47:23 +0000
@@ -138,7 +138,7 @@
 
     def destroySelf(self):
         """See `IProductRelease`."""
-        assert self.files.count() == 0, (
+        assert self._files.count() == 0, (
             "You can't delete a product release which has files associated "
             "with it.")
         SQLBase.destroySelf(self)

=== modified file 'lib/lp/registry/model/productseries.py'
--- lib/lp/registry/model/productseries.py	2012-10-05 03:00:21 +0000
+++ lib/lp/registry/model/productseries.py	2012-10-06 23:47:23 +0000
@@ -211,7 +211,7 @@
         """See `HasMilestonesMixin`."""
         return (Milestone.productseries == self)
 
-    @cachedproperty
+    @property
     def releases(self):
         """See `IProductSeries`."""
         store = Store.of(self)
@@ -229,6 +229,14 @@
         result = result.order_by(Desc('datereleased'))
         return DecoratedResultSet(result, decorate)
 
+    @cachedproperty
+    def _cached_releases(self):
+        return self.releases
+
+    def getCachedReleases(self):
+        """See `IProductSeries`."""
+        return self._cached_releases
+
     @property
     def release_files(self):
         """See `IProductSeries`."""


Follow ups