コード例 #1
0
ファイル: httperror.py プロジェクト: BillSeitz/tank
def method_not_allowed(environ, start_response, exc=None):
    """
    Package up special format method not allowed.
    """
    allow = ', '.join(environ['selector.methods'])
    exc = HTTPException('The method specified in the Request-Line '
        'is not allowed for the resource identified by the Request-URI.')
    exc.status = '405 Method Not Allowed'
    return send_error(environ, start_response, exc, allow=allow)
コード例 #2
0
def method_not_allowed(environ, start_response, exc=None):
    """
    Package up special format method not allowed.
    """
    allow = ', '.join(environ['selector.methods'])
    exc = HTTPException(
        'The method specified in the Request-Line '
        'is not allowed for the resource identified by the Request-URI.')
    exc.status = '405 Method Not Allowed'
    return send_error(environ, start_response, exc, allow=allow)
コード例 #3
0
    a DEFAULT_TEXT string is used.
    """

    def __call__(self, environ, start_response, exc_info=None):
        try:
            return self.application(environ, start_response)
        except HTTPException, exc:
            return self._send_response(environ, start_response, exc_info, exc)
        except:
            etype, value, traceb = sys.exc_info()
            exception_text = ''.join(traceback.format_exception(
                etype, value, traceb, None))
            print >> environ['wsgi.errors'], exception_text
            LOGGER.warn(exception_text)

            exc = HTTPException(exception_text)
            exc.status = '500 server error'
            return self._send_response(environ, start_response,
                    sys.exc_info(), exc)

    def _send_response(self, environ, start_response, exc_info, exc):
        """
        Change the content-type header to text/html, load up the
        relevant error tiddler, format its contents, and send out
        the text.
        """
        status = exc.status.split(' ', 1)[0]
        output = exc.body()

        html_out = _is_html_out(environ, status)