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
=== modified file 'lib/lp/services/features/__init__.py'
--- lib/lp/services/features/__init__.py 2010-08-05 23:40:32 +0000
+++ lib/lp/services/features/__init__.py 2010-09-12 05:23:50 +0000
@@ -26,4 +26,9 @@
2626
27def getFeatureFlag(flag):27def getFeatureFlag(flag):
28 """Get the value of a flag for this thread's scopes."""28 """Get the value of a flag for this thread's scopes."""
29 return per_thread.features.getFlag(flag)29 # Workaround for bug 631884 - features have two homes, threads and
30 # requests.
31 features = getattr(per_thread, 'features', None)
32 if features is None:
33 return None
34 return features.getFlag(flag)
3035
=== modified file 'lib/lp/services/features/tests/test_flags.py'
--- lib/lp/services/features/tests/test_flags.py 2010-08-20 20:31:18 +0000
+++ lib/lp/services/features/tests/test_flags.py 2010-09-12 05:23:50 +0000
@@ -129,6 +129,12 @@
129 finally:129 finally:
130 per_thread.features = None130 per_thread.features = None
131131
132 def test_threadGetFlagNoContext(self):
133 # If there is no context, please don't crash. workaround for the root
134 # cause in bug 631884.
135 per_thread.features = None
136 self.assertEqual(None, getFeatureFlag('ui.icing'))
137
132 def testLazyScopeLookup(self):138 def testLazyScopeLookup(self):
133 # feature scopes may be a bit expensive to look up, so we do it only139 # feature scopes may be a bit expensive to look up, so we do it only
134 # when it will make a difference to the result.140 # when it will make a difference to the result.