Commit 7d2dbf4b by Eric Fischer

Waffle Utils cleanup

Turn override into a sensible default that calls both of the
for_request and in_model submethods, which are themselves still
avaiable if needed.
parent 1503e5f7
......@@ -1451,7 +1451,7 @@ class ProgressPageTests(ModuleStoreTestCase):
@ddt.unpack
def test_progress_queries(self, enable_waffle, initial, subsequent):
self.setup_course()
with grades_waffle().override_in_model(ASSUME_ZERO_GRADE_IF_ABSENT, active=enable_waffle):
with grades_waffle().override(ASSUME_ZERO_GRADE_IF_ABSENT, active=enable_waffle):
with self.assertNumQueries(initial), check_mongo_calls(1):
self._get_progress_page()
......
......@@ -61,12 +61,13 @@ class WaffleSwitchPlus(WafflePlus):
"""
Overrides the active value for the given switch for the duration of this
contextmanager.
Note: The value is overridden in the request cache, not in the model.
Note: The value is overridden in the request cache AND in the model.
"""
previous_active = self.is_enabled(switch_name)
try:
self.override_for_request(switch_name, active)
yield
with self.override_in_model(switch_name, active):
yield
finally:
self.override_for_request(switch_name, previous_active)
......@@ -85,12 +86,12 @@ class WaffleSwitchPlus(WafflePlus):
"""
Overrides the active value for the given switch for the duration of this
contextmanager.
Note: The value is overridden in the request cache AND in the model.
Note: The value is overridden in the model, not the request cache.
"""
with self.override(switch_name, active):
namespaced_switch_name = self._namespaced_setting_name(switch_name)
with waffle_override_switch(namespaced_switch_name, active):
yield
namespaced_switch_name = self._namespaced_setting_name(switch_name)
with waffle_override_switch(namespaced_switch_name, active):
log.info(u"%sSwitch '%s' set to %s in model.", self.log_prefix, namespaced_switch_name, active)
yield
@property
def _cached_switches(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment