Simplify hack to obtain waffle module names
Instead of going up the stacktrace to find the module names of waffle
flags and switches, we manually pass the module __name__ whenever the
flag is created. This is similar to `logging.getLogger(__name__)`
standard behaviour.
As the waffle classes are used outside of edx-platform, we make the new
module_name argument an optional keyword argument. This will change once
we pull waffle_utils outside of edx-platform.
Note that the module name is normally only required to view the list of
existing waffle flags and switches. The module name should not be
necessary to verify if a flag is enabled. Thus, maybe it would make
sense to create a `add` class methor similar to:
class WaffleFlag:
@classmethod
def add(cls, namespace, flag, module):
instance = cls(namespace, flag)
cls._class_instances.add((instance, module))
This commit is contained in:
@@ -36,11 +36,13 @@ def waffle_flags():
|
||||
ENABLE_CHECKLISTS_QUALITY = CourseWaffleFlag(
|
||||
waffle_namespace=waffle_flags(),
|
||||
flag_name=u'enable_checklists_quality',
|
||||
module_name=__name__,
|
||||
)
|
||||
|
||||
SHOW_REVIEW_RULES_FLAG = CourseWaffleFlag(
|
||||
waffle_namespace=waffle_flags(),
|
||||
flag_name=u'show_review_rules',
|
||||
module_name=__name__,
|
||||
)
|
||||
|
||||
# Waffle flag to redirect to the library authoring MFE.
|
||||
@@ -58,4 +60,5 @@ SHOW_REVIEW_RULES_FLAG = CourseWaffleFlag(
|
||||
REDIRECT_TO_LIBRARY_AUTHORING_MICROFRONTEND = WaffleFlag(
|
||||
waffle_namespace=waffle_flags(),
|
||||
flag_name='library_authoring_mfe',
|
||||
module_name=__name__,
|
||||
)
|
||||
|
||||
@@ -90,7 +90,7 @@ NEVER = lambda x: False
|
||||
ALWAYS = lambda x: True
|
||||
|
||||
|
||||
highlights_setting = WaffleSwitch(u'dynamic_pacing', u'studio_course_update')
|
||||
highlights_setting = WaffleSwitch('dynamic_pacing', 'studio_course_update', __name__)
|
||||
|
||||
|
||||
def _filter_entrance_exam_grader(graders):
|
||||
|
||||
@@ -81,6 +81,7 @@ WAFFLE_STUDIO_FLAG_NAMESPACE = WaffleFlagNamespace(name=u'studio')
|
||||
ENABLE_VIDEO_UPLOAD_PAGINATION = CourseWaffleFlag(
|
||||
waffle_namespace=WAFFLE_STUDIO_FLAG_NAMESPACE,
|
||||
flag_name=u'enable_video_upload_pagination',
|
||||
module_name=__name__,
|
||||
)
|
||||
# Default expiration, in seconds, of one-time URLs used for uploading videos.
|
||||
KEY_EXPIRATION_IN_SECONDS = 86400
|
||||
|
||||
@@ -12,6 +12,7 @@ MATERIAL_RECOMPUTE_ONLY = 'MATERIAL_RECOMPUTE_ONLY'
|
||||
MATERIAL_RECOMPUTE_ONLY_FLAG = CourseWaffleFlag(
|
||||
waffle_namespace=WAFFLE_NAMESPACE,
|
||||
flag_name=MATERIAL_RECOMPUTE_ONLY,
|
||||
module_name=__name__,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user