예제 #1
0
def process_resource(request, resource_id):  
    if validateMimeFormat(request):           
        LOGGING.info("Redirecting to /%s/%s" % (DATA, resource_id))
        return HttpResponseSeeOther('/%s/%s' % (DATA, resource_id))
    if 'text/html' in http_accept(request):
        LOGGING.info("Redirecting to /%s/%s" % (PAGE, resource_id))
        return HttpResponseSeeOther('/%s/%s' % (PAGE, resource_id))
    return Http404()
예제 #2
0
def process_data(request, resource_id):
    if 'text/html' in http_accept(request):
        return process_resource(request, resource_id = None)
    
    req_format = validateMimeFormat(request)
    if req_format is None:
        return process_resource(request, resource_id)
            
    tmp_g = find_resource_by_id(resource_id)           
    return HttpResponse(tmp_g.serialize(format = req_format), 
                            mimetype = FORMAT_MAP.get(req_format))  
예제 #3
0
def insert(request):
    '''
        Inserts in the triplestore a new annotation under the "ANNO_SUBMITTED" graph
    '''
    try:
        req_format = _validateFormat(request)
        
    except SerializeError as e:
        messages.add_message(request, messages.ERROR, e)
        return mm_render_to_response_error(request, '400.html', 400)
    
    if isPOST(request) or isOPTIONS(request):
        triples = request.body
        tmp_g = insert_rdf(triples, req_format, graph=ANNO_SUBMITTED) 
        ret_format = validateMimeFormat(request)
        if ret_format is None:
            ret_format = req_format
        return HttpResponse(__serialize(tmp_g, req_format = ret_format), content_type=FORMAT_MAP.get(ret_format))