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


Python HTTPException.__init__方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from werkzeug.exceptions import HTTPException [as 別名]
# 或者: from werkzeug.exceptions.HTTPException import __init__ [as 別名]
def __init__(self, description=None, response=None):
        super(Exception, self).__init__()
        if description is not None:
            self.description = description
        self.response = response 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:7,代碼來源:exceptions.py

示例2: wrap

# 需要導入模塊: from werkzeug.exceptions import HTTPException [as 別名]
# 或者: from werkzeug.exceptions.HTTPException import __init__ [as 別名]
def wrap(cls, exception, name=None):
        """Create an exception that is a subclass of the calling HTTP
        exception and the ``exception`` argument.

        The first argument to the class will be passed to the
        wrapped ``exception``, the rest to the HTTP exception. If
        ``self.args`` is not empty, the wrapped exception message is
        added to the HTTP exception description.

        .. versionchanged:: 0.15
            The description includes the wrapped exception message.
        """

        class newcls(cls, exception):
            def __init__(self, arg=None, *args, **kwargs):
                super(cls, self).__init__(*args, **kwargs)

                if arg is None:
                    exception.__init__(self)
                else:
                    exception.__init__(self, arg)

            def get_description(self, environ=None):
                out = super(cls, self).get_description(environ=environ)

                if self.args:
                    out += "<p><pre><code>{}: {}</code></pre></p>".format(
                        exception.__name__, escape(exception.__str__(self))
                    )

                return out

        newcls.__module__ = sys._getframe(1).f_globals.get("__name__")
        newcls.__name__ = name or cls.__name__ + exception.__name__
        return newcls 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:37,代碼來源:exceptions.py

示例3: __init__

# 需要導入模塊: from werkzeug.exceptions import HTTPException [as 別名]
# 或者: from werkzeug.exceptions.HTTPException import __init__ [as 別名]
def __init__(self, description=None, response=None):
        Exception.__init__(self)
        if description is not None:
            self.description = description
        self.response = response 
開發者ID:jpush,項目名稱:jbox,代碼行數:7,代碼來源:exceptions.py

示例4: wrap

# 需要導入模塊: from werkzeug.exceptions import HTTPException [as 別名]
# 或者: from werkzeug.exceptions.HTTPException import __init__ [as 別名]
def wrap(cls, exception, name=None):
        """This method returns a new subclass of the exception provided that
        also is a subclass of `BadRequest`.
        """
        class newcls(cls, exception):

            def __init__(self, arg=None, *args, **kwargs):
                cls.__init__(self, *args, **kwargs)
                exception.__init__(self, arg)
        newcls.__module__ = sys._getframe(1).f_globals.get('__name__')
        newcls.__name__ = name or cls.__name__ + exception.__name__
        return newcls 
開發者ID:jpush,項目名稱:jbox,代碼行數:14,代碼來源:exceptions.py


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