當前位置: 首頁>>代碼示例>>Python>>正文


Python exceptions.HTTPException類代碼示例

本文整理匯總了Python中werkzeug.exceptions.HTTPException的典型用法代碼示例。如果您正苦於以下問題:Python HTTPException類的具體用法?Python HTTPException怎麽用?Python HTTPException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了HTTPException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

	def __init__(self, data, description=None):
		"""
		param: data: A dictionary containing the field errors that occured
		param: description: Optional description to send through
		"""
		HTTPException.__init__(self)
		self.data = data
開發者ID:stikks,項目名稱:moshalashi,代碼行數:7,代碼來源:__init__.py

示例2: handle_error

 def handle_error(self, e):
     if e.__class__ in self._error_handlers:
         handler = self._error_handlers[e.__class__]
         result = handler(e)
         e = HTTPException(str(e))
         e.data, e.code = result if len(result) == 2 else (result, 500)
     return super(Api, self).handle_error(e)
開發者ID:alexa-infra,項目名稱:flask-restplus,代碼行數:7,代碼來源:api.py

示例3: __init__

    def __init__(self, description, locator="", code=400):
        self.code = code
        self.description = description
        self.locator = locator
        logging.exception(description)

        HTTPException.__init__(self)
開發者ID:kalxas,項目名稱:pywps,代碼行數:7,代碼來源:exceptions.py

示例4: __init__

    def __init__(self, description, locator="", code=400):
        self.code = code
        self.description = description
        self.locator = locator
        msg = 'Exception: code: %s, locator: %s, description: %s' % (self.code, self.description, self.locator)
        LOGGER.exception(msg)

        HTTPException.__init__(self)
開發者ID:jan-rudolf,項目名稱:pywps,代碼行數:8,代碼來源:exceptions.py

示例5: test_handle_error_401_sends_challege_default_realm

    def test_handle_error_401_sends_challege_default_realm(self, api):
        exception = HTTPException()
        exception.code = 401
        exception.data = {'foo': 'bar'}

        resp = api.handle_error(exception)
        assert resp.status_code == 401
        assert resp.headers['WWW-Authenticate'] == 'Basic realm="flask-restplus"'
開發者ID:bedge,項目名稱:flask-restplus,代碼行數:8,代碼來源:test_api_legacy.py

示例6: abort

def abort(response, status_code=None):
    if isinstance(response, basestring):
        response = make_response(response)
    if status_code:
        response.status_code = status_code
    e = HTTPException(response=response)
    e.code = getattr(response, 'status_code', 0)
    raise e
開發者ID:pprolancer,項目名稱:flexrest,代碼行數:8,代碼來源:helper.py

示例7: __init__

    def __init__(message=None, data=None, code=400, **kwargs):
        data = data or kwargs
        if instanceof(message, str):
            data, message = message, None
        if message:
            data["message"] = message

        response = jsonify(status="fail", data=data)
        response.status_code = status_code
        HTTPException.__init__(self, message, response)
        self.code = code
開發者ID:gvsurenderreddy,項目名稱:ipop-stat,代碼行數:11,代碼來源:errors.py

示例8: test_handle_error_401_sends_challege_default_realm

    def test_handle_error_401_sends_challege_default_realm(self):
        api = restplus.Api(self.app, serve_challenge_on_401=True)
        exception = HTTPException()
        exception.code = 401
        exception.data = {'foo': 'bar'}

        with self.app.test_request_context('/foo'):
            resp = api.handle_error(exception)
            self.assertEqual(resp.status_code, 401)
            self.assertEqual(resp.headers['WWW-Authenticate'],
                             'Basic realm="flask-restful"')
開發者ID:gazpachoking,項目名稱:flask-restplus,代碼行數:11,代碼來源:test_api.py

示例9: create_app

def create_app(settings_override=None, register_security_blueprint=False):
    app = factory.create_app(__name__, __path__, settings_override, register_security_blueprint)

    # Init API endpoints for models
    api_manager.init_app(app)

    # Setup security async email send
    security_ctx = app.extensions['security']

    @security_ctx.send_mail_task
    def delay_security_email(msg):  # pylint: disable=unused-variable
        tasks.send_security_email.delay(msg)

    # Register custom error handlers so they all return JSON
    if not app.debug:
        for http_exception_class in HTTPException.__subclasses__():
            app.errorhandler(http_exception_class.code)(handle_error)

    return app
開發者ID:derek-miller,項目名稱:inspinia,代碼行數:19,代碼來源:__init__.py

示例10: init

def init(self, description=None, response=None, traceback=None):
    self.traceback = traceback
    HTTPException.__init__(self, description, response)
開發者ID:dmonroy,項目名稱:spa,代碼行數:3,代碼來源:exceptions.py

示例11: __init__

 def __init__(self, article_name, original_link, description=None):
     HTTPException.__init__(self, description)
     self.article_name = article_name
     self.original_link = original_link
開發者ID:Alwnikrotikz,項目名稱:cdpedia,代碼行數:4,代碼來源:web_app.py

示例12: get_headers

 def get_headers(self, environ):
     headers = HTTPException.get_headers(self, environ)
     headers.append(('WWW-Authenticate', 'Basic realm="MCM API"'))
     return headers
開發者ID:oscarfonts,項目名稱:icub-mon,代碼行數:4,代碼來源:auth.py

示例13: __init__

 def __init__(self, code, description):
     HTTPException.__init__(self)
     self.code = code
     self.description = description
開發者ID:01org,項目名稱:intel-cmt-cat,代碼行數:4,代碼來源:rest.py

示例14: __init__

 def __init__(self, location):
     HTTPException.__init__(self)
     self.location = location
開發者ID:diazona,項目名稱:Modulo,代碼行數:3,代碼來源:auth.py

示例15: http_ensure

def http_ensure(case, msg, code=400):
    "if not case, raise a client error exception (by default)"
    if not case:
        ex = HTTPException(msg)
        ex.code = code
        raise ex
開發者ID:elifesciences,項目名稱:bot-lax-adaptor,代碼行數:6,代碼來源:api.py


注:本文中的werkzeug.exceptions.HTTPException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。