def index(request):
    if request.is_ajax() and request.method == "POST":
        try:
            user_settings = json.loads(request.REQUEST['settings'])
        except (KeyError, ValueError):
            user_settings = {}
        keys  = set(request.REQUEST.getlist('keys[]'))
        ekeys = set(Storage.get_keys(settings=user_settings))
        data  = {
            'new':    list(Storage.get_info(list(ekeys-keys)[:25])),
            'delete': list(keys-ekeys),
        }
        return HttpResponse(json.dumps(data), 'application/json')
    request.META['CSRF_COOKIE_USED'] = True
    return render_to_response('requests_monitor/base.html', {},
        RequestContext(request))
 def process_response(self, request, response):
     ret = super(RequestMonitorMiddleware, self).process_response(request,
         response)
     ident = thread.get_ident()
     toolbar = self.__class__.toolbars.get(ident)
     if toolbar is not None:
         if all(f.process_response(request, response) for f in self.__class__.filters[ident]):
             self.__class__.debug_toolbars[ident] = toolbar
             if not ('gzip' not in response.get('Content-Encoding', '') and \
              response.get('Content-Type', '').split(';')[0] in _HTML_TYPES):
                 for panel in toolbar.panels:
                     panel.process_response(request, response)
             Storage.add(request=request, response=response, toolbar=toolbar)
             del self.__class__.debug_toolbars[ident]
         del self.__class__.toolbars[ident]
         del self.__class__.filters[ident]
     return ret
def response_content(request, key):
    data = Storage.get(str(key))
    if data is None or 'response_content' not in data:
        raise Http404
    return HttpResponse(data['response_content'])
def request(request, key):
    data = Storage.get(str(key))
    if data is None:
        raise Http404
    data['response_content'] = 'response_content' in data
    return HttpResponse(json.dumps(data), 'application/json')