author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Tue, 12 Jan 2010 15:12:51 +0100 | |
branch | stable |
changeset 4220 | 713434095f0d |
parent 4212 | ab6573088b4a |
child 4252 | 6c4f109c2b03 |
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 |
|
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
5 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
7 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 8 |
""" |
9 |
__docformat__ = "restructuredtext en" |
|
10 |
||
11 |
from cubicweb._exceptions import * |
|
12 |
||
13 |
class PublishException(CubicWebException): |
|
14 |
"""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
|
15 |
|
0 | 16 |
class RequestError(PublishException): |
17 |
"""raised when a request can't be served because of a bad input""" |
|
18 |
||
19 |
class NothingToEdit(RequestError): |
|
20 |
"""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
|
21 |
|
0 | 22 |
class NotFound(RequestError): |
23 |
"""raised when a 404 error should be returned""" |
|
24 |
||
25 |
class Redirect(PublishException): |
|
26 |
"""raised to redirect the http request""" |
|
27 |
def __init__(self, location): |
|
28 |
self.location = location |
|
29 |
||
30 |
class DirectResponse(Exception): |
|
31 |
def __init__(self, response): |
|
32 |
self.response = response |
|
33 |
||
34 |
class StatusResponse(Exception): |
|
35 |
def __init__(self, status, content=''): |
|
36 |
self.status = int(status) |
|
37 |
self.content = content |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
320
diff
changeset
|
38 |
|
0 | 39 |
class ExplicitLogin(AuthenticationError): |
40 |
"""raised when a bad connection id is given or when an attempt to establish |
|
41 |
a connection failed""" |
|
42 |
||
43 |
class InvalidSession(CubicWebException): |
|
44 |
"""raised when a session id is found but associated session is not found or |
|
45 |
invalid |
|
46 |
""" |
|
47 |
||
48 |
class RemoteCallFailed(RequestError): |
|
49 |
"""raised when a json remote call fails |
|
50 |
""" |
|
51 |
def __init__(self, reason=''): |
|
320 | 52 |
#super(RequestError, self).__init__() # XXX require py >= 2.5 |
53 |
RequestError.__init__(self) |
|
0 | 54 |
self.reason = reason |
55 |
||
56 |
def dumps(self): |
|
57 |
import simplejson |
|
58 |
return simplejson.dumps({'reason': self.reason}) |