コード例 #1
0
def vocabulary_file(request, list_name, file_format):
    try:
        vocab = Vocabulary.objects.get(name__exact=list_name)
    except:
        raise http.Http404
    if string.upper(file_format) == 'XML':
        vocabulary_object = VocabularyHandler.xml_response(vocab)
    elif string.upper(file_format) == 'PY':
        vocabulary_object = VocabularyHandler.py_response(vocab)
    elif string.upper(file_format) == 'JSON':
        vocabulary_object = VocabularyHandler.json_response(vocab)
    elif string.upper(file_format) == 'TKL':
        vocabulary_object = VocabularyHandler.tkl_response(vocab)

    return HttpResponse(vocabulary_object.vocab_file, content_type=vocabulary_object.vocab_mimetype)
コード例 #2
0
def vocabulary_file(request, list_name, file_format):
    try:
        vocab = Vocabulary.objects.get(name__exact=list_name)
    except (Vocabulary.DoesNotExist, Vocabulary.MultipleObjectsReturned):
        raise http.Http404
    if file_format.upper() == 'XML':
        vocabulary_object = VocabularyHandler.xml_response(vocab)
    elif file_format.upper() == 'PY':
        vocabulary_object = VocabularyHandler.py_response(vocab)
    elif file_format.upper() == 'JSON':
        vocabulary_object = VocabularyHandler.json_response(vocab)
    elif file_format.upper() == 'TKL':
        vocabulary_object = VocabularyHandler.tkl_response(vocab)
    else:
        raise Http404
    return HttpResponse(vocabulary_object.vocab_file,
                        content_type=vocabulary_object.vocab_mimetype)