24 from cubicweb.utils import json_dumps |
24 from cubicweb.utils import json_dumps |
25 |
25 |
26 |
26 |
27 class DirectResponse(Exception): |
27 class DirectResponse(Exception): |
28 """Used to supply a twitted HTTP Response directly""" |
28 """Used to supply a twitted HTTP Response directly""" |
|
29 |
29 def __init__(self, response): |
30 def __init__(self, response): |
30 self.response = response |
31 self.response = response |
31 |
32 |
32 class InvalidSession(CubicWebException): |
33 class InvalidSession(CubicWebException): |
33 """raised when a session id is found but associated session is not found or |
34 """raised when a session id is found but associated session is not found or |
42 self.status = kwargs.pop('status', http_client.OK) |
43 self.status = kwargs.pop('status', http_client.OK) |
43 super(PublishException, self).__init__(*args, **kwargs) |
44 super(PublishException, self).__init__(*args, **kwargs) |
44 |
45 |
45 class LogOut(PublishException): |
46 class LogOut(PublishException): |
46 """raised to ask for deauthentication of a logged in user""" |
47 """raised to ask for deauthentication of a logged in user""" |
|
48 |
47 def __init__(self, url=None): |
49 def __init__(self, url=None): |
48 super(LogOut, self).__init__() |
50 super(LogOut, self).__init__() |
49 self.url = url |
51 self.url = url |
50 |
52 |
51 class Redirect(PublishException): |
53 class Redirect(PublishException): |
52 """raised to redirect the http request""" |
54 """raised to redirect the http request""" |
|
55 |
53 def __init__(self, location, status=http_client.SEE_OTHER): |
56 def __init__(self, location, status=http_client.SEE_OTHER): |
54 super(Redirect, self).__init__(status=status) |
57 super(Redirect, self).__init__(status=status) |
55 self.location = location |
58 self.location = location |
56 |
59 |
57 class StatusResponse(PublishException): |
60 class StatusResponse(PublishException): |
81 super(NothingToEdit, self).__init__(*args, **kwargs) |
84 super(NothingToEdit, self).__init__(*args, **kwargs) |
82 |
85 |
83 class ProcessFormError(RequestError): |
86 class ProcessFormError(RequestError): |
84 """raised when posted data can't be processed by the corresponding field |
87 """raised when posted data can't be processed by the corresponding field |
85 """ |
88 """ |
|
89 |
86 def __init__(self, *args, **kwargs): |
90 def __init__(self, *args, **kwargs): |
87 kwargs.setdefault('status', http_client.BAD_REQUEST) |
91 kwargs.setdefault('status', http_client.BAD_REQUEST) |
88 super(ProcessFormError, self).__init__(*args, **kwargs) |
92 super(ProcessFormError, self).__init__(*args, **kwargs) |
89 |
93 |
90 class NotFound(RequestError): |
94 class NotFound(RequestError): |
96 super(NotFound, self).__init__(*args, **kwargs) |
100 super(NotFound, self).__init__(*args, **kwargs) |
97 |
101 |
98 class RemoteCallFailed(RequestError): |
102 class RemoteCallFailed(RequestError): |
99 """raised when a json remote call fails |
103 """raised when a json remote call fails |
100 """ |
104 """ |
|
105 |
101 def __init__(self, reason='', status=http_client.INTERNAL_SERVER_ERROR): |
106 def __init__(self, reason='', status=http_client.INTERNAL_SERVER_ERROR): |
102 super(RemoteCallFailed, self).__init__(reason, status=status) |
107 super(RemoteCallFailed, self).__init__(reason, status=status) |
103 self.reason = reason |
108 self.reason = reason |
104 |
109 |
105 def dumps(self): |
110 def dumps(self): |