1
2
3
4
5
6
7 import webob.exc
8
9 from restkit import errors
10
12 """
13 Wrapper to return webob exceptions instead of restkit errors. Usefull
14 for those who want to build `WSGI <http://wsgi.org/wsgi/>`_ applications
15 speaking directly to others via HTTP.
16
17 To do it place somewhere in your application the function
18 `wrap_exceptions`::
19
20 wrap_exceptions()
21
22 It will automatically replace restkit errors by webob exceptions.
23 """
24
25 - def __init__(self, msg=None, http_code=None, response=None):
26 webob.exc.WSGIHTTPException.__init__(self)
27
28 http_code = http_code or 500
29 klass = webob.exc.status_map[http_code]
30 self.code = http_code
31 self.title = klass.title
32 self.status = '%s %s' % (self.code, self.title)
33 self.explanation = msg
34 self.response = response
35
36 self.msg = msg
37
39 """
40 The status as an integer
41 """
42 return int(self.status.split()[0])
45 status_int = property(_status_int__get, _status_int__set,
46 doc=_status_int__get.__doc__)
47
49 return self.explanation
51 self.explanation = msg or ''
52 message = property(_get_message, _set_message)
53
54 webob_exceptions = False
61