Merge lp:~lifeless/launchpad/bug-631884 into lp:launchpad

Proposed by Robert Collins
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: 11535
Proposed branch: lp:~lifeless/launchpad/bug-631884
Merge into: lp:launchpad
Diff against target: 31 lines (+12/-1)
2 files modified
lib/lp/services/features/__init__.py (+6/-1)
lib/lp/services/features/tests/test_flags.py (+6/-0)
To merge this branch: bzr merge lp:~lifeless/launchpad/bug-631884
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+35219@code.launchpad.net

Commit message

Workaround bug 631884.

Description of the change

This works around bug 631884 permitting code that depends on features to be introduced without breaking throughout the test suite: we still need to address the root cause of bug 631884 and probably want participations in general to drive flags, but that is made difficult due to bug 623199.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

As I said on IRC, I don't really think the comment is very helpful, but I can see the need for the code change.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/services/features/__init__.py'
2--- lib/lp/services/features/__init__.py 2010-08-05 23:40:32 +0000
3+++ lib/lp/services/features/__init__.py 2010-09-12 05:23:50 +0000
4@@ -26,4 +26,9 @@
5
6 def getFeatureFlag(flag):
7 """Get the value of a flag for this thread's scopes."""
8- return per_thread.features.getFlag(flag)
9+ # Workaround for bug 631884 - features have two homes, threads and
10+ # requests.
11+ features = getattr(per_thread, 'features', None)
12+ if features is None:
13+ return None
14+ return features.getFlag(flag)
15
16=== modified file 'lib/lp/services/features/tests/test_flags.py'
17--- lib/lp/services/features/tests/test_flags.py 2010-08-20 20:31:18 +0000
18+++ lib/lp/services/features/tests/test_flags.py 2010-09-12 05:23:50 +0000
19@@ -129,6 +129,12 @@
20 finally:
21 per_thread.features = None
22
23+ def test_threadGetFlagNoContext(self):
24+ # If there is no context, please don't crash. workaround for the root
25+ # cause in bug 631884.
26+ per_thread.features = None
27+ self.assertEqual(None, getFeatureFlag('ui.icing'))
28+
29 def testLazyScopeLookup(self):
30 # feature scopes may be a bit expensive to look up, so we do it only
31 # when it will make a difference to the result.