twisted.web.weberror.Error

Here are the examples of the python api twisted.web.weberror.Error taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

Example 1

Project: flumotion Source File: httpfile.py
    def _terminateRequest(self, body, request):
        if body == server.NOT_DONE_YET:
            # _renderRequest will return NOT_DONE_YET if it started serving the
            # file. This means the callback chain started by _renderRequest has
            # finished and we're currently serving the file.
            return
        if isinstance(body, Failure):
            # Something went wrong, log it
            self.warning("Failure during request rendering: %s",
                         log.getFailureMessage(body))
            if body.check(weberror.Error):
                err = body.value
                page = weberror.ErrorPage(err.status, err.message,
                                          err.response)
            elif body.check(fileprovider.UnavailableError):
                page = self.serviceUnavailable
            elif body.check(fileprovider.AccessError):
                page = self.forbiddenResource
            elif body.check(fileprovider.NotFoundError):
                page = self.childNotFound
            else:
                page = self.internalServerError
            body = page.render(request)
        if body:
            # the callback chain from _renderRequest chose to return a string
            # body, write it out to the client
            request.write(body)
        self.debug('[fd %5d] Terminate request %r',
                   request.transport.fileno(), request)
        request.finish()