示例#1
0
    def post(self, request, *args, **kwargs):
        """
        Clear the logs before a POST-request.

        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        Log.clear()

        return super().post(request, *args, **kwargs)
示例#2
0
    def get(self, request, *args, **kwargs):
        """
        Only clear the log AFTER a GET-request. This way, POST-requests are
        included in the network logs.

        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        if not self.keep_logs and not request.GET.get('keep-logs', False):
            Log.clear()

        return super().get(request, *args, **kwargs)
示例#3
0
    def dispatch(self, request, *args, **kwargs):
        clear_logs = not self.keep_logs and not request.GET.get('keep-logs', False)
        if clear_logs:
            Log.clear()

        try:
            self._pre_dispatch(request, *args, **kwargs)

            result = super().dispatch(request, *args, **kwargs)

            self._post_dispatch(request, *args, **kwargs)
        except (ClientError, HTTPError) as e:
            return render_exception_to_response(request, e)

        return result