launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00968
[Merge] lp:~lifeless/launchpad/bug-631884 into lp:launchpad/devel
Robert Collins has proposed merging lp:~lifeless/launchpad/bug-631884 into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
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.
--
https://code.launchpad.net/~lifeless/launchpad/bug-631884/+merge/35219
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/launchpad/bug-631884 into lp:launchpad/devel.
=== 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:43 +0000
@@ -26,4 +26,9 @@
def getFeatureFlag(flag):
"""Get the value of a flag for this thread's scopes."""
- return per_thread.features.getFlag(flag)
+ # Workaround for bug 631884 - features have two homes, threads and
+ # requests.
+ features = getattr(per_thread, 'features', None)
+ if features is None:
+ return None
+ return features.getFlag(flag)
=== 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:43 +0000
@@ -129,6 +129,12 @@
finally:
per_thread.features = None
+ def test_threadGetFlagNoContext(self):
+ # If there is no context, please don't crash. workaround for the root
+ # cause in bug 631884.
+ per_thread.features = None
+ self.assertEqual(None, getFeatureFlag('ui.icing'))
+
def testLazyScopeLookup(self):
# feature scopes may be a bit expensive to look up, so we do it only
# when it will make a difference to the result.