Process the response.

        If the response is ``HttpResponse``, does nothing. Otherwise,
        serializes, formats and validates the response.

        :param response: resource's response. This can be
           - ``None``,
           - django's ``HttpResponse``
           - devil's ``Response``
           - dictionary (or list of dictionaries)
           - object (or list of objects) that are first serialized into dict
             using ``self.factory``.
           - plaintext
        :returns: Django's ``HttpResponse``

def _process_response(self, response, request):
        """ Process the response.

        If the response is ``HttpResponse``, does nothing. Otherwise,
        serializes, formats and validates the response.

        :param response: resource's response. This can be
           - ``None``,
           - django's ``HttpResponse``
           - devil's ``Response``
           - dictionary (or list of dictionaries)
           - object (or list of objects) that are first serialized into dict
             using ``self.factory``.
           - plaintext
        :returns: Django's ``HttpResponse``
        """

        def coerce_response():
            """ Coerce the response object into devil structure. """
            if not isinstance(response, Response):
                return Response(0, response)
            return response

        if isinstance(response, HttpResponse):
            # we don't do anything if resource returns django's http response
            return response

        devil_res = coerce_response()
        if devil_res.content and devil_res.get_code_num() in (0, 200, 201):
            # serialize, format and validate
            serialized_res = devil_res.content = self._serialize_object(devil_res.content, request)
            formatted_res = self._format_response(request, devil_res)
            self._validate_output_data(response, serialized_res, formatted_res, request)
        else:
            # no data -> format only
            formatted_res = self._format_response(request, devil_res)
        return formatted_res