Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
a2749983
Commit
a2749983
authored
4 years ago
by
Régis Behmo
Browse files
Options
Downloads
Patches
Plain Diff
Add deprecation warning comments to waffle_utils code
parent
98ffa347
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openedx/core/djangoapps/waffle_utils/__init__.py
+11
-23
11 additions, 23 deletions
openedx/core/djangoapps/waffle_utils/__init__.py
openedx/core/djangoapps/waffle_utils/testutils.py
+1
-0
1 addition, 0 deletions
openedx/core/djangoapps/waffle_utils/testutils.py
with
12 additions
and
23 deletions
openedx/core/djangoapps/waffle_utils/__init__.py
+
11
−
23
View file @
a2749983
"""
Extra utilities for waffle: most classes are defined in edx_toggles.toggles, but we keep here some extra classes for
usage within edx-platform. These classes cover course override use cases.
Usage:
WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name=
'
my_namespace
'
)
# Use CourseWaffleFlag when you are in the context of a course.
SOME_COURSE_FLAG = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE,
'
some_course_feature
'
, __name__)
You can check this flag in code using the following::
SOME_COURSE_FLAG.is_enabled(course_key)
To test WaffleSwitchNamespace, use the provided context managers. For example:
with WAFFLE_SWITCHES.override(waffle.ESTIMATE_FIRST_ATTEMPTED, active=True):
...
Also see ``WAFFLE_FLAG_CUSTOM_ATTRIBUTES`` and docstring for _set_waffle_flag_attribute
for temporarily instrumenting/monitoring waffle flag usage.
Extra utilities for waffle: most classes are defined in edx_toggles.toggles (https://edx-toggles.readthedocs.io/), but
we keep here some extra classes for usage within edx-platform. These classes cover course override use cases.
"""
import
logging
from
contextlib
import
contextmanager
...
...
@@ -38,6 +18,13 @@ log = logging.getLogger(__name__)
class
WaffleSwitchNamespace
(
BaseWaffleSwitchNamespace
):
"""
Waffle switch namespace that implements custom overriding methods. We should eventually get rid of this class.
To test WaffleSwitchNamespace, use the provided context managers. For example:
with WAFFLE_SWITCHES.override(waffle.ESTIMATE_FIRST_ATTEMPTED, active=True):
...
Note: this should eventually be deprecated in favour of a dedicated `override_waffle_switch` context manager.
"""
@contextmanager
...
...
@@ -130,7 +117,8 @@ class WaffleFlag(BaseWaffleFlag):
class
CourseWaffleFlag
(
WaffleFlag
):
"""
Represents a single waffle flag that can be forced on/off for a course.
Represents a single waffle flag that can be forced on/off for a course. This class should be used instead of
WaffleFlag when in the context of a course.
Uses a cached waffle namespace.
...
...
This diff is collapsed.
Click to expand it.
openedx/core/djangoapps/waffle_utils/testutils.py
+
1
−
0
View file @
a2749983
...
...
@@ -3,6 +3,7 @@ Test utilities for waffle utilities.
"""
# Import from edx-toggles to preserve import paths
# TODO: Deprecate and remove
# pylint: disable=unused-import
from
edx_toggles.toggles.testutils
import
override_waffle_flag
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment