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


Python Response.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
    def __init__(
        self,
        detail=None,
        headers=None,
        comment=None,
        body_template=None,
        json_formatter=None,
        **kw
    ):
        status = '%s %s' % (self.code, self.title)
        Response.__init__(self, status=status, **kw)
        Exception.__init__(self, detail)
        self.detail = self.message = detail
        if headers:
            self.headers.extend(headers)
        self.comment = comment
        if body_template is not None:
            self.body_template = body_template
            self.body_template_obj = Template(body_template)
        if json_formatter is not None:
            self._json_formatter = json_formatter

        if self.empty_body:
            del self.content_type
            del self.content_length
开发者ID:Pylons,项目名称:pyramid,代码行数:27,代码来源:httpexceptions.py

示例2: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
 def __init__(self, code=None, errors=None):
     if code:
         self.code = code
     if errors:
         self.errors = errors
     body = {
         'code': self.code,
         'errors': self.errors
         }
     Response.__init__(self, json.dumps(body))
     self.status = str(self.code)
     self.content_type = 'application/json'
开发者ID:POV7DandelionKing,项目名称:cyoc,代码行数:14,代码来源:errors.py

示例3: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
    def __init__(self):
        # explicitly avoid calling the HTTPException init magic
        if not self.empty_body:
            Response.__init__(self, status=self.code,
                              json_body=self.json_body())
        else:
            Response.__init__(self, status=self.code)
        Exception.__init__(self)
        self.detail = self.message

        if self.empty_body:
            del self.content_type
            del self.content_length
开发者ID:crankycoder,项目名称:ichnaea,代码行数:15,代码来源:exceptions.py

示例4: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
    def __init__(self, code=None, json_data=None, **kw):
        if json_data is None:
            json_data = ''

        if code in HTTP_STATUSES:
            status = HTTP_STATUSES[code]
        else:
            status = HTTP_STATUSES[httpcode.InternalServerError]
            json_data = {'error': 'JSONResponse: Unable to determine HTTP status code.'}

        Response.__init__(self, status=status, body=json.dumps(json_data),
            content_type='application/json', **kw)

        self.charset = 'utf-8'
开发者ID:sigsergv,项目名称:pyrone,代码行数:16,代码来源:jsonhttpresponse.py

示例5: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
    def __init__(self, request):

        # NOTE I: Pode parecer excesso de zelo... Mas, mesmo não havendo,
        # necessariamente, "views" para esses métodos eu optei por tentar
        # fechar a conexão AQUI TAMBÉM para garantir que um "raise exception"
        # da vida impeça a conexão de ser fechada! By Questor

        # NOTE II: Tentar fechar a conexão de qualquer forma!
        # -> Na criação da conexão "coautocommit=True"!
        # By Questor
        try:
            if request.context.session.is_active:
                request.context.session.close()
        except:
            pass

        self._error_message = self.title
        self.request = request
        Response.__init__(self, self.get_error(), status=self.code)
        self.content_type = 'application/json'
开发者ID:lightbase,项目名称:LBGenerator,代码行数:22,代码来源:error.py

示例6: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
 def __init__(self, **kw):
     Response.__init__(self, **kw)
     Exception.__init__(self)
开发者ID:uceo,项目名称:uceo-2015,代码行数:5,代码来源:views.py

示例7: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
 def __init__(self, errors, status=400):
     body = {'status': 'error', 'errors': errors}
     Response.__init__(self, json.dumps(body, use_decimal=True))
     self.status = status
     self.content_type = 'application/json'
开发者ID:abourget,项目名称:cornice,代码行数:7,代码来源:util.py

示例8: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
 def __init__(self, error):
     Response.__init__(self, utils.object2json(error), status=self.code)
     self.content_type = 'application/json'
开发者ID:VictorMedeiros,项目名称:LBGenerator,代码行数:5,代码来源:exceptions.py

示例9: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
 def __init__(self, error):
     Response.__init__(self, json.dumps(error), status=self.code)
     self.content_type = 'application/json'
开发者ID:UPCnet,项目名称:bigmax,代码行数:5,代码来源:exceptions.py

示例10: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
 def __init__(self, msg='Unauthorized'):
     body = {'status': 401, 'message': msg}
     Response.__init__(self, json.dumps(body))
     self.status = 401
     self.content_type = 'application/json'
开发者ID:jdoranster,项目名称:inkblot,代码行数:7,代码来源:views.py

示例11: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
 def __init__(self, errors, status=400):
     body = {'errors': errors}
     Response.__init__(self, dumps(body))
     self.status = status
     self.content_type = 'application/json'
开发者ID:SmartDelivery,项目名称:ichnaea,代码行数:7,代码来源:error.py

示例12: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
 def __init__(self, request):
     self._error_message = self.title
     self.request = request
     Response.__init__(self, self.get_error(), status=self.code)
     self.content_type = 'application/json'
开发者ID:VictorMedeiros,项目名称:LBGenerator,代码行数:7,代码来源:error.py

示例13: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
 def __init__(self, errors, code=400):
     self.code = code
     body = {'status': "error", "errors": errors}
     Response.__init__(self, status=code, body=render("json", body))
     self.content_type = 'application/json'
开发者ID:CroissanceCommune,项目名称:autonomie,代码行数:7,代码来源:rest.py

示例14: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
 def __init__(self, msg=None):
     body = {'status': self.code, 'message': msg or self.msg}
     Response.__init__(self, json.dumps(body))
     self.status = self.code
     self.content_type = 'application/json'
开发者ID:podhmo,项目名称:komet,代码行数:7,代码来源:httpexceptions.py

示例15: __init__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import __init__ [as 别名]
 def __init__(self):
     # explicitly avoid calling the HTTPException init magic
     Response.__init__(self, status=self.code, json_body=self.json_body())
     Exception.__init__(self)
     self.detail = self.message
开发者ID:JaredKerim-Mozilla,项目名称:ichnaea,代码行数:7,代码来源:exceptions.py


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