Beispiel #1
0
def session_detail(request, session_id):
    
    session = get_object_or_404(HttpSession, pk=session_id)
    html_formatter = HtmlFormatter()

    run_session(session)
    
    pretty_request = html_formatter.format(session.get_raw_request())
    
    if session.time_completed:
        if not session.http_error:
            pretty_response = html_formatter.format(session.http_response)
            session_time = session.time_completed - session.time_requested
            elapsed_milliseconds = session_time.microseconds / 1000.0
    else:
        pretty_response = render_to_string('spyglass/fragment_loading_placeholder.html', {'session_id': session.id})
        elapsed_milliseconds = None
    
    use_advanced_form = (len(session.http_body) != 0) or (len(session.http_headers) != 0)
    form, http_header_form = session_and_headers_form(session=session)
        
    context = {
        'session': session,
        'pretty_request': pretty_request,
        'pretty_response': pretty_response,
        'request_linenos': html_line_numbers(pretty_request),
        'response_linenos': html_line_numbers(pretty_response),
        'elapsed_milliseconds': elapsed_milliseconds,
        'form': form,
        'http_header_form': http_header_form,
        'use_advanced_form': use_advanced_form,
    }
    
    return render_to_response('spyglass/session_detail.html', context, context_instance=RequestContext(request))    
Beispiel #2
0
def session_detail(request, session_id):
    
    session = get_object_or_404(HttpSession, pk=session_id)
    html_formatter = HtmlFormatter()

    run_session(session)
    
    pretty_request = html_formatter.format(session.get_raw_request())

    use_advanced_form = (len(session.http_body) != 0) or (len(session.http_headers) != 0)
    form, http_header_form = session_and_headers_form(session=session)

    response_template = open(os.path.join(settings.MEDIA_ROOT, 'mustache/session.mustache')).read()
    formatted_response = pystache.render(response_template, mustache_context_for_session(session))
    
    context = {
        'session': session,
        'pretty_request': pretty_request,
        'request_linenos': html_line_numbers(pretty_request),
        
        'show_placeholder': not session_is_ready(session),
        'formatted_response': formatted_response,
        
        'form': form,
        'http_header_form': http_header_form,
        'use_advanced_form': use_advanced_form,
    }
    
    return render_to_response('spyglass/session_detail.html', context, context_instance=RequestContext(request))