author | sylvain.thenault@logilab.fr |
Thu, 14 May 2009 12:50:34 +0200 | |
changeset 1813 | 4e4333bb56b3 |
parent 1802 | d628defebc17 |
child 1977 | 606923dff11b |
permissions | -rw-r--r-- |
0 | 1 |
# pylint: disable-msg=W0401,W0614 |
2 |
"""exceptions used in the core of the CubicWeb web application |
|
3 |
||
4 |
:organization: Logilab |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
320
diff
changeset
|
5 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
0 | 6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
7 |
""" |
|
8 |
__docformat__ = "restructuredtext en" |
|
9 |
||
10 |
from cubicweb._exceptions import * |
|
11 |
||
12 |
class PublishException(CubicWebException): |
|
13 |
"""base class for publishing related exception""" |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
320
diff
changeset
|
14 |
|
0 | 15 |
class RequestError(PublishException): |
16 |
"""raised when a request can't be served because of a bad input""" |
|
17 |
||
18 |
class NothingToEdit(RequestError): |
|
19 |
"""raised when an edit request doesn't specify any eid to edit""" |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
320
diff
changeset
|
20 |
|
0 | 21 |
class NotFound(RequestError): |
22 |
"""raised when a 404 error should be returned""" |
|
23 |
||
24 |
class Redirect(PublishException): |
|
25 |
"""raised to redirect the http request""" |
|
26 |
def __init__(self, location): |
|
27 |
self.location = location |
|
28 |
||
29 |
class DirectResponse(Exception): |
|
30 |
def __init__(self, response): |
|
31 |
self.response = response |
|
32 |
||
33 |
class StatusResponse(Exception): |
|
34 |
def __init__(self, status, content=''): |
|
35 |
self.status = int(status) |
|
36 |
self.content = content |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
320
diff
changeset
|
37 |
|
0 | 38 |
class ExplicitLogin(AuthenticationError): |
39 |
"""raised when a bad connection id is given or when an attempt to establish |
|
40 |
a connection failed""" |
|
41 |
||
42 |
class InvalidSession(CubicWebException): |
|
43 |
"""raised when a session id is found but associated session is not found or |
|
44 |
invalid |
|
45 |
""" |
|
46 |
||
47 |
class RemoteCallFailed(RequestError): |
|
48 |
"""raised when a json remote call fails |
|
49 |
""" |
|
50 |
def __init__(self, reason=''): |
|
320 | 51 |
#super(RequestError, self).__init__() # XXX require py >= 2.5 |
52 |
RequestError.__init__(self) |
|
0 | 53 |
self.reason = reason |
54 |
||
55 |
def dumps(self): |
|
56 |
import simplejson |
|
57 |
return simplejson.dumps({'reason': self.reason}) |