Ejemplo n.º 1
0
 def process_response(self, request, response):
     log_entry = HttpLogEntry(
         url=request.path,
         method=request.method,
         status_code=response.status_code
     )
     log_entry.save()
     return response
Ejemplo n.º 2
0
    def test_create(self, ):

        ModelLogEntry.objects.all().delete()
        http = HttpLogEntry(data="crap")
        http.save()

        log_all = ModelLogEntry.objects.filter(action='create')

        self.assertEqual(1, log_all.count())
        log = log_all.get()
        self.assertEqual(log.action, 'create')
        self.assertEqual(log.model_name, 'logger.httplogentry')
        self.assertEqual(log.changed_pk, http.pk)
Ejemplo n.º 3
0
    def test_create(self,):

        ModelLogEntry.objects.all().delete()
        http = HttpLogEntry(data="crap")
        http.save()

        log_all = ModelLogEntry.objects.filter(action='create')

        self.assertEqual(1, log_all.count())
        log = log_all.get()
        self.assertEqual(log.action, 'create')
        self.assertEqual(log.model_name, 'logger.httplogentry')
        self.assertEqual(log.changed_pk, http.pk)
Ejemplo n.º 4
0
    def process_response(self, request, response):
        headers = [
                (name, val)
                for name, val in request.META.items()
                if isinstance(val, basestring)]
        to_log = {
                'method': request.method,
                'headers': headers,
                'path': request.path,
                'cookies': request.COOKIES,
                'params': request.REQUEST,
                'code': response.status_code,
        }
        entry = HttpLogEntry(data=to_log)
        entry.save()

        return response