-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various improvements to the waffle classes
We expose the legacy classes in a `legacy` module, and the new ones in `__future__`. We add monitoring to ensure that IDAs switch to the new API. Note that the `module_name` constructor argument is no longer optional. We also allow the use of non-namespaced flag and switches. As per: https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/waffle_utils/docs/decisions/0004-waffle-util-namespacing.rst We want to be able to easily migrate existing non-namespaced waffle.Switch and waffle.Flag objects. We avoid relying on a boolean argument passed to the constructor, and instead implement a `.validate_name()` method to be overridden by child classes. Using this method, we provide NonNamespacedWaffleFlag/Switch classes and expose them via the _future__ API.
- Loading branch information
Showing
14 changed files
with
297 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
""" | ||
Expose new-style waffle classes. In the future, these imports will be moved to edx_toggles.toggles. Applications that | ||
want to migrate to the new-style API can do so right now by importing from this module. | ||
""" | ||
# pylint: disable=unused-import | ||
from .internal.setting_toggle import SettingDictToggle, SettingToggle | ||
from .internal.waffle.flag import NonNamespacedWaffleFlag, WaffleFlag | ||
from .internal.waffle.switch import NonNamespacedWaffleSwitch, WaffleSwitch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
Waffle classes in the context of edx-platform and other IDAs. | ||
Usage: | ||
For waffle flags:: | ||
SOME_FLAG = WaffleFlag('some_namespace_prefix.some_feature', module_name=__name__) | ||
For waffle switches: | ||
SOME_SWITCH = WaffleSwitch('some_namespace_prefix.some_feature', module_name=__name__) | ||
The namespace prefix is used to categorize waffle objects. | ||
For both flags and switched, the waffle value can be checked in code by writing:: | ||
SOME_WAFFLE.is_enabled() | ||
To test these WaffleFlags, see edx_toggles.toggles.testutils. | ||
In the above examples, you will use Django Admin "waffle" section to configure | ||
for a flag named: my_namespace.some_course_feature | ||
Also see ``WAFFLE_FLAG_CUSTOM_ATTRIBUTES`` and docstring for _set_waffle_flag_attribute | ||
for temporarily instrumenting/monitoring waffle flag usage. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.