def process_page(request, resource_id = None): if 'text/html' not in http_accept(request): return process_resource(request, resource_id) tmp_g = find_resource_by_id(resource_id) context = {'results': tmp_g.serialize()} return mm_render_to_response(request, context, 'viewer.html')
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()
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))
def processHEAD(request, return_content = False): ''' Returns an httplib.HTTPRequest ''' graph = get_graph_from_request(request) accept = http_accept(request) if accept not in FORMAT_MAP.values(): return HttpResponse(status = 406) g = None if graph is None: g = ConjunctiveGraph(store=CharmeMiddleware.get_store()) else: g = generate_graph(CharmeMiddleware.get_store(), URIRef(graph)) content = g.serialize(format = rdf_format_from_mime(accept)) if return_content: return HttpResponse(content = content) return HttpResponse()