← Back to team overview

launchpad-dev team mailing list archive

Re: [Branch ~launchpad-pqm/launchpad/devel] Rev 9769: [r=bac][ui=none][bug=455812,

 

On Sat, Oct 24, 2009 at 09:40:29AM -0000, noreply@xxxxxxxxxxxxx wrote:
> Merge authors:
>   Edwin Grubbs (edwin-grubbs)
> Related merge proposals:
>   https://code.launchpad.net/~edwin-grubbs/launchpad/bug-458169-distroseries-timeout/+merge/13851
>   proposed by: Edwin Grubbs (edwin-grubbs)
>   review: Approve - Brad Crittenden (bac)
> ------------------------------------------------------------
> revno: 9769 [merge]
> committer: Launchpad Patch Queue Manager <launchpad@xxxxxxxxxxxxxxxxx>
> branch nick: launchpad
> timestamp: Sat 2009-10-24 10:37:08 +0100
> message:
>   [r=bac][ui=none][bug=455812,
>   	458169] Fixed timeouts on distroseries page and distro milestone page.
> modified:
>   lib/lp/registry/browser/productseries.py
>   lib/lp/registry/model/distribution.py


> === modified file 'lib/lp/registry/model/distribution.py'
> --- lib/lp/registry/model/distribution.py	2009-10-16 15:00:55 +0000
> +++ lib/lp/registry/model/distribution.py	2009-10-23 16:20:14 +0000
> @@ -325,10 +325,7 @@
>              return (2, self.name)
>          return (3, self.name)
>  
> -    # XXX: 2008-01-29 kiko: This is used in a number of places and given it's
> -    # already listified, why not spare the trouble of regenerating this as a
> -    # cachedproperty? Answer: because it breaks tests.
> -    @property
> +    @cachedproperty('_cached_serieses')
>      def serieses(self):
>          """See `IDistribution`."""
>          ret = DistroSeries.selectBy(distribution=self)
> @@ -1497,6 +1494,9 @@
>          if owner.inTeam(self.driver) and not owner.inTeam(self.owner):
>              # This driver is a release manager.
>              series.driver = owner
> +
> +        if safe_hasattr(self, '_cached_serieses'):
> +            del self._cached_serieses
>          return series

A change like this deserves an explicit test. Having @cachedproperty on
the model itself is dangerous, since you need to be careful to
invalidate the cache when needed. Therefore you should have a test
showing that the cache is invalided whenever the series information
changes.


-- 
Björn Tillenius | https://launchpad.net/~bjornt