'Returns a function to use as the check_before_waffle_callback.
Arguments:
course_key (CourseKey): The course to check for override before
checking waffle.'

def _get_course_override_callback(self, course_key):

    def course_override_callback(namespaced_flag_name):
        '\n                                                Returns    True/False    if    the    flag    was    forced    on    or    off    for    the    provided\n                                                course.        Returns    None    if    the    flag    was    not    overridden.\n\n                                                Note:    Has    side    effect    of    caching    the    override    value.\n\n                                                Arguments:\n                                                                namespaced_flag_name    (String):    A    namespaced    version    of    the    flag\n                                                                                to    check.\n                                                '
        cache_key = u'{}.{}'.format(namespaced_flag_name, unicode(course_key))
        force_override = self.waffle_namespace._cached_flags.get(cache_key)
        if (force_override is None):
            force_override = WaffleFlagCourseOverrideModel.override_value(namespaced_flag_name, course_key)
            self.waffle_namespace._cached_flags[cache_key] = force_override
        if (force_override == WaffleFlagCourseOverrideModel.ALL_CHOICES.on):
            return True
        if (force_override == WaffleFlagCourseOverrideModel.ALL_CHOICES.off):
            return False
        return None
    return course_override_callback
