def documents_for(locale, topics=None, products=None):
 documents = _documents_for(locale, topics, products)
 if (locale != settings.WIKI_DEFAULT_LANGUAGE):
  l10n_document_ids = [d['document_parent_id'] for d in documents if ('document_parent_id' in d)]
  en_documents = _documents_for(locale=settings.WIKI_DEFAULT_LANGUAGE, products=products, topics=topics)
  fallback_documents = [d for d in en_documents if (d['id'] not in l10n_document_ids)]
 else:
  fallback_documents = None
 return (documents, fallback_documents)

def documents_for ( locale , topics = None , products = None ) : documents = _documents_for ( locale , topics , products ) if ( locale != settings . WIKI_DEFAULT_LANGUAGE ) : l10n_document_ids = [ d [ 'document_parent_id' ] for d in documents if ( 'document_parent_id' in d ) ] en_documents = _documents_for ( locale = settings . WIKI_DEFAULT_LANGUAGE , products = products , topics = topics ) fallback_documents = [ d for d in en_documents if ( d [ 'id' ] not in l10n_document_ids ) ] else : fallback_documents = None return ( documents , fallback_documents )
returns a tuple of lists of articles that apply to topics and products .