def get_object_fallback(cls, title, locale, default=None, **kwargs):
    try:
        return cls.objects.get(title=title, locale=locale, **kwargs)
    except (cls.DoesNotExist, IOError):
        pass

    # Fallback
    try:
        default_lang_doc = cls.objects.get(
            title=title, locale=settings.WIKI_DEFAULT_LANGUAGE, **kwargs)

        # Return the translation of this English item:
        if hasattr(default_lang_doc, 'translated_to'):
            trans = default_lang_doc.translated_to(locale)
            if trans and trans.current_revision:
                return trans

        # Follow redirects internally in an attempt to find a
        # translation of the final redirect target in the requested
        # locale. This happens a lot when an English article is
        # renamed and a redirect is left in its wake: we wouldn't want
        # the non-English user to be linked to the English redirect,
        # which would happily redirect them to the English final
        # article.
        if hasattr(default_lang_doc, 'redirect_document'):
            target = default_lang_doc.redirect_document()
            if target:
                trans = target.translated_to(locale)
                if trans and trans.current_revision:
                    return trans

        # Return the English item:
        return default_lang_doc
    # Okay, all else failed
    except (cls.DoesNotExist, IOError):
        return default
Return an instance of cls matching title and locale, or fall
dataset/ETHPy150Open mozilla/kitsune/kitsune/sumo/parser.py/get_object_fallback