'Returns and caches whether the provided flag is active.
If the flag value is already cached in the request, it is returned.
If check_before_waffle_callback is supplied, it is called before
checking waffle.
If check_before_waffle_callback returns None, or if it is not supplied,
then waffle is used to check the flag.
Important: Caching for the check_before_waffle_callback must be handled
by the callback itself.
Arguments:
flag_name (String): The name of the flag to check.
check_before_waffle_callback (function): (Optional) A function that
will be checked before continuing on to waffle. If
check_before_waffle_callback(namespaced_flag_name) returns True
or False, it is returned. If it returns None, then waffle is
used.
flag_undefined_default (Boolean): A default value to be returned if
the waffle flag is to be checked, but doesn\'t exist.'

def is_flag_active(self, flag_name, check_before_waffle_callback=None, flag_undefined_default=None):

    namespaced_flag_name = self._namespaced_name(flag_name)
    if check_before_waffle_callback:
        value = check_before_waffle_callback(namespaced_flag_name)
    if (value is None):
        value = self._cached_flags.get(namespaced_flag_name)
        if (value is None):
            if (flag_undefined_default is not None):
                try:
                    Flag.objects.get(name=namespaced_flag_name)
                except Flag.DoesNotExist:
                    value = flag_undefined_default
            if (value is None):
                value = flag_is_active(get_request(), namespaced_flag_name)
            self._cached_flags[namespaced_flag_name] = value
    return value
