def _get_cached_values(instance, translated_model, language_code, use_fallback=False):
    """
    Fetch an cached field.
    """
    if not appsettings.PARLER_ENABLE_CACHING or not instance.pk or instance._state.adding:
        return None

    key = get_translation_cache_key(translated_model, instance.pk, language_code)
    values = cache.get(key)
    if not values:
        return None

    # Check for a stored fallback marker
    if values.get('__FALLBACK__', False):
        # Internal trick, already set the fallback marker, so no query will be performed.
        instance._translations_cache[translated_model][language_code] = MISSING

        # Allow to return the fallback language instead.
        if use_fallback:
            lang_dict = get_language_settings(language_code)
            # iterate over list of fallback languages, which should be already
            # in proper order
            for fallback_lang in lang_dict['fallbacks']:
                if fallback_lang != language_code:
                    return _get_cached_values(
                        instance, translated_model, fallback_lang,
                        use_fallback=False
                    )
        return None

    values['master'] = instance
    values['language_code'] = language_code
    return values
def _get_cached_values ( instance , translated_model , language_code , use_fallback = False ) : if not appsettings . PARLER_ENABLE_CACHING or not instance . pk or instance . _state . adding : return None key = get_translation_cache_key ( translated_model , instance . pk , language_code ) values = cache . get ( key ) if not values : return None if values . get ( '__FALLBACK__' , False ) : instance . _translations_cache [ translated_model ] [ language_code ] = MISSING if use_fallback : lang_dict = get_language_settings ( language_code ) for fallback_lang in lang_dict [ 'fallbacks' ] : if fallback_lang != language_code : return _get_cached_values ( instance , translated_model , fallback_lang , use_fallback = False ) return None values [ 'master' ] = instance values [ 'language_code' ] = language_code return values
Fetch an cached field.