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
 try:
  default_lang_doc = cls.objects.get(title=title, locale=settings.WIKI_DEFAULT_LANGUAGE, **kwargs)
  if hasattr(default_lang_doc, 'translated_to'):
   trans = default_lang_doc.translated_to(locale)
   if (trans and trans.current_revision):
    return trans
  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 default_lang_doc
 except (cls.DoesNotExist, IOError):
  return default

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 try : default_lang_doc = cls . objects . get ( title = title , locale = settings . WIKI_DEFAULT_LANGUAGE , ** kwargs ) if hasattr ( default_lang_doc , 'translated_to' ) : trans = default_lang_doc . translated_to ( locale ) if ( trans and trans . current_revision ) : return trans 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 default_lang_doc except ( cls . DoesNotExist , IOError ) : return default
return an instance of cls matching title and locale .