def statements_more_get(req_dict): stmt_result, attachments = parse_more_request(req_dict['more_id']) if isinstance(stmt_result, dict): content_length = len(json.dumps(stmt_result)) else: content_length = len(stmt_result) mime_type = "application/json" # If there are attachments, include them in the payload if attachments: stmt_result, mime_type, content_length = build_response(stmt_result) resp = HttpResponse(stmt_result, content_type=mime_type, status=200) # If not, just dump the stmt_result else: if isinstance(stmt_result, basestring): resp = HttpResponse(stmt_result, content_type=mime_type, status=200) else: resp = HttpResponse(json.dumps(stmt_result), content_type=mime_type, status=200) # Add consistent header and set content-length try: resp['X-Experience-API-Consistent-Through'] = str(Statement.objects.latest('stored').stored) except: resp['X-Experience-API-Consistent-Through'] = str(datetime.now()) resp['Content-Length'] = str(content_length) # If it's a HEAD request if req_dict['method'].lower() != 'get': resp.body = '' return resp
def statements_more_get(req_dict): stmt_result, attachments = parse_more_request(req_dict['more_id']) if isinstance(stmt_result, dict): content_length = len(json.dumps(stmt_result)) else: content_length = len(stmt_result) mime_type = "application/json" # If there are attachments, include them in the payload if attachments: stmt_result, mime_type, content_length = build_response(stmt_result) resp = HttpResponse(stmt_result, content_type=mime_type, status=200) # If not, just dump the stmt_result else: if isinstance(stmt_result, basestring): resp = HttpResponse(stmt_result, content_type=mime_type, status=200) else: resp = HttpResponse(json.dumps(stmt_result), content_type=mime_type, status=200) resp['Content-Length'] = str(content_length) return resp
def statements_more_get(req_dict): stmt_result, attachments = parse_more_request(req_dict['more_id']) if isinstance(stmt_result, dict): content_length = len(json.dumps(stmt_result)) else: content_length = len(stmt_result) mime_type = "application/json" # If there are attachments, include them in the payload if attachments: stmt_result, mime_type, content_length = build_response(stmt_result) resp = HttpResponse(stmt_result, content_type=mime_type, status=200) # If not, just dump the stmt_result else: if isinstance(stmt_result, basestring): resp = HttpResponse( stmt_result, content_type=mime_type, status=200) else: resp = HttpResponse(json.dumps(stmt_result), content_type=mime_type, status=200) resp['Content-Length'] = str(content_length) return resp