当前位置: 首页>>代码示例>>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;未经允许,请勿转载。