Code review comment for lp:~allenap/launchpad/cache-experiment-roll-out

Revision history for this message
Gavin Panella (allenap) wrote :

Hi Rob,

If you get a chance, please could you review my workaround for bug
628762
(diff attached). It passes the full test suite, hurrah :)

Thanks, Gavin.

1=== modified file 'lib/lp/services/propertycache.py'
2--- lib/lp/services/propertycache.py 2010-08-31 11:03:41 +0000
3+++ lib/lp/services/propertycache.py 2010-09-02 12:52:40 +0000
4@@ -184,3 +184,32 @@
5 name = name_or_function.__name__
6 populate = name_or_function
7 return CachedProperty(name=name, populate=populate)
8+
9+
10+# XXX: GavinPanella 2010-09-02 bug=628762: There are some weird adaption
11+# failures when running the full test suite. All that follows is a temporary,
12+# mostly non-Zope, workaround.
13+
14+_IPropertyCache = IPropertyCache
15+_IPropertyCacheManager = IPropertyCacheManager
16+
17+def IPropertyCache(target):
18+ """Return the `IPropertyCache` for `target`.
19+
20+ Note: this is a workaround; see bug 628762.
21+ """
22+ if _IPropertyCache.providedBy(target):
23+ return target
24+ else:
25+ return get_default_cache(target)
26+
27+def IPropertyCacheManager(target):
28+ """Return the `IPropertyCacheManager` for `target`.
29+
30+ Note: this is a workaround; see bug 628762.
31+ """
32+ cache = IPropertyCache(target)
33+ if isinstance(cache, DefaultPropertyCache):
34+ return DefaultPropertyCacheManager(cache)
35+ else:
36+ return PropertyCacheManager(cache)

« Back to merge proposal