当前位置: 首页>>代码示例>>Python>>正文


Python util.status_generic_reasons方法代码示例

本文整理汇总了Python中webob.util.status_generic_reasons方法的典型用法代码示例。如果您正苦于以下问题:Python util.status_generic_reasons方法的具体用法?Python util.status_generic_reasons怎么用?Python util.status_generic_reasons使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webob.util的用法示例。


在下文中一共展示了util.status_generic_reasons方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from webob import util [as 别名]
# 或者: from webob.util import status_generic_reasons [as 别名]
def __init__(self, code=500, title="", explanation=""):
        self.code = code
        # There is a strict rule about constructing status line for HTTP:
        # '...Status-Line, consisting of the protocol version followed by a
        # numeric status code and its associated textual phrase, with each
        # element separated by SP characters'
        # (http://www.faqs.org/rfcs/rfc2616.html)
        # 'code' and 'title' can not be empty because they correspond
        # to numeric status code and its associated text
        if title:
            self.title = title
        else:
            try:
                self.title = status_reasons[self.code]
            except KeyError:
                generic_code = self.code // 100
                self.title = status_generic_reasons[generic_code]
        self.explanation = explanation
        super(ConvertedException, self).__init__() 
开发者ID:cloudbase,项目名称:vdi-broker,代码行数:21,代码来源:exception.py

示例2: _status__set

# 需要导入模块: from webob import util [as 别名]
# 或者: from webob.util import status_generic_reasons [as 别名]
def _status__set(self, value):
        if isinstance(value, int):
            self.status_code = value
            return
        if PY3: # pragma: no cover
            if isinstance(value, bytes):
                value = value.decode('ascii')
        elif isinstance(value, text_type):
            value = value.encode('ascii')
        if not isinstance(value, str):
            raise TypeError(
                "You must set status to a string or integer (not %s)"
                % type(value))
        if ' ' not in value:
             try:
                value += ' ' + status_reasons[int(value)]
             except KeyError:
                value += ' ' + status_generic_reasons[int(value) // 100]
        self._status = value 
开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:21,代码来源:response.py

示例3: __init__

# 需要导入模块: from webob import util [as 别名]
# 或者: from webob.util import status_generic_reasons [as 别名]
def __init__(self, code, title="", explanation=""):
        self.code = code
        # There is a strict rule about constructing status line for HTTP:
        # '...Status-Line, consisting of the protocol version followed by a
        # numeric status code and its associated textual phrase, with each
        # element separated by SP characters'
        # (http://www.faqs.org/rfcs/rfc2616.html)
        # 'code' and 'title' can not be empty because they correspond
        # to numeric status code and its associated text
        if title:
            self.title = title
        else:
            try:
                self.title = woutil.status_reasons[self.code]
            except KeyError:
                msg = "Improper or unknown HTTP status code used: %d"
                LOG.error(msg, code)
                self.title = woutil.status_generic_reasons[self.code // 100]
        self.explanation = explanation
        super(ConvertedException, self).__init__() 
开发者ID:openstack,项目名称:masakari,代码行数:22,代码来源:exception.py

示例4: __init__

# 需要导入模块: from webob import util [as 别名]
# 或者: from webob.util import status_generic_reasons [as 别名]
def __init__(self, code, title="", explanation=""):
        self.code = code
        # There is a strict rule about constructing status line for HTTP:
        # '...Status-Line, consisting of the protocol version followed by a
        # numeric status code and its associated textual phrase, with each
        # element separated by SP characters'
        # (http://www.faqs.org/rfcs/rfc2616.html)
        # 'code' and 'title' can not be empty because they correspond
        # to numeric status code and its associated text
        if title:
            self.title = title
        else:
            try:
                self.title = woutil.status_reasons[self.code]
            except KeyError:
                msg = _LE("Improper or unknown HTTP status code used: %d")
                LOG.error(msg, code)
                self.title = woutil.status_generic_reasons[self.code // 100]
        self.explanation = explanation
        super(ConvertedException, self).__init__() 
开发者ID:BU-NU-CLOUD-SP16,项目名称:Trusted-Platform-Module-nova,代码行数:22,代码来源:exception.py

示例5: _status_code__set

# 需要导入模块: from webob import util [as 别名]
# 或者: from webob.util import status_generic_reasons [as 别名]
def _status_code__set(self, code):
        try:
            self._status = '%d %s' % (code, status_reasons[code])
        except KeyError:
            self._status = '%d %s' % (code, status_generic_reasons[code // 100]) 
开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:7,代码来源:response.py


注:本文中的webob.util.status_generic_reasons方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。