def trace_view(request):
 if (request.method.upper() != 'TRACE'):
  return HttpResponseNotAllowed('TRACE')
 elif request.body:
  return HttpResponseBadRequest('TRACE requests MUST NOT include an entity')
 else:
  protocol = request.META['SERVER_PROTOCOL']
  t = Template('{{ method }} {{ uri }} {{ version }}', name='TRACE Template')
  c = Context({'method': request.method, 'uri': request.path, 'version': protocol})
  return HttpResponse(t.render(c))

def trace_view ( request ) : if ( request . method . upper ( ) != 'TRACE' ) : return HttpResponseNotAllowed ( 'TRACE' ) elif request . body : return HttpResponseBadRequest ( 'TRACE requests MUST NOT include an entity' ) else : protocol = request . META [ 'SERVER_PROTOCOL' ] t = Template ( '{{ method }} {{ uri }} {{ version }}' , name = 'TRACE Template' ) c = Context ( { 'method' : request . method , 'uri' : request . path , 'version' : protocol } ) return HttpResponse ( t . render ( c ) )
a simple view that expects a trace request and echoes its status line .