Пример #1
0
    def __init__(
        self,
        detail=None,
        headers=None,
        comment=None,
        body_template=None,
        json_formatter=None,
        **kw,
    ):
        Response.__init__(self, status="%s %s" % (self.code, self.title), **kw)
        Exception.__init__(self, detail)

        if headers:
            self.headers.extend(headers)
        self.detail = detail
        self.comment = comment

        if body_template is not None:
            self.body_template = body_template
            self.body_template_obj = Template(body_template)

        if self.empty_body:
            del self.content_type
            del self.content_length

        if json_formatter is not None:
            self.json_formatter = json_formatter
Пример #2
0
    def __init__(
        self,
        detail=None,
        headers=None,
        comment=None,
        body_template=None,
        json_formatter=None,
        **kw
    ):
        Response.__init__(self, status="%s %s" % (self.code, self.title), **kw)
        Exception.__init__(self, detail)

        if headers:
            self.headers.extend(headers)
        self.detail = detail
        self.comment = comment

        if body_template is not None:
            self.body_template = body_template
            self.body_template_obj = Template(body_template)

        if self.empty_body:
            del self.content_type
            del self.content_length

        if json_formatter is not None:
            self.json_formatter = json_formatter
Пример #3
0
 def __init__(self, detail=None, headers=None, title=None, comment=None, explanation=None, **kw):
     Response.__init__(self,
                       status='%s %s' % (self.code, self.title),
                       **kw)
     Exception.__init__(self, detail)
     if headers:
         self.headers.extend(headers)
     self.title = title or self.title
     self.detail = detail
     self.comment = comment
     self.explanation = explanation or self.explanation
     if self.empty_body:
         del self.content_type
         del self.content_length
Пример #4
0
 def __init__(self, msg=u'Not Found.'):
     body = {'status': 404, 'message': msg}
     Response.__init__(self, json.dumps(body))
     self.status = 404
     self.content_type = 'application/json'
Пример #5
0
 def __init__(self, msg=u'Bad request, missing data.'):
     body = {'status': 400, 'message': msg}
     Response.__init__(self, json.dumps(body))
     self.status = 400
     self.content_type = 'application/json'
Пример #6
0
 def __init__(self, msg=u'Unauthorized'):
     body = {'status': 401, 'message': msg}
     Response.__init__(self, json.dumps(body))
     self.status = 401
     self.content_type = 'application/json'
Пример #7
0
 def __init__(self, message='Exception'):
     Response.__init__(self, status=self.status)
     Exception.__init__(self, message)
Пример #8
0
 def __init__(self, message='Exception'):
     Response.__init__(self, status=self.status)
     Exception.__init__(self, message)