Esempio n. 1
0
 def redirect(self, aResponse, aCode, aPath):
     """
     Send a redirection message
     """
     aResponse.set_header('content-type', "application/json")
     aResponse.set_header('Location', aPath)
     wMessage = utils.prepareMessage()
     aResponse.send_content(aCode, json.dumps(wMessage))
Esempio n. 2
0
    def showMessage(self, aResponse, aCode, aMessage):
        """
        Display a message

        :param aReponse: Response handler
        :param aCode: http-code of the response
        :param aMessage: a message
        """
        aResponse.set_header('content-type', "application/json")
        wMessage = utils.prepareMessage()
        wMessage['content'] = aMessage
        aResponse.send_content(aCode, json.dumps(wMessage))
Esempio n. 3
0
    def showError(self, aResponse, aCode, aException):
        """
        Display an error message containing the exception message. The exception is also logged

        :param aReponse: Response handler
        :param aCode: http-code of the response
        :param aException: the exception
        """
        # Trace the exception in the log
        _logger.exception("Exception : %s", aException)

        aResponse.set_header('content-type', "application/json")
        wMessage = utils.prepareMessage()
        wMessage['content'] = str(aException.orig)
        aResponse.send_content(aCode, json.dumps(wMessage))