author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 26 Jan 2010 13:36:55 +0100 | |
changeset 4366 | d51f28ba9399 |
parent 4252 | 6c4f109c2b03 |
child 5186 | f3c2cb460ad9 |
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 |
|
3387
a357d4147eee
[forms] work-in-progress, big editcontroller refactoring: let fields/widgets process posted data
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
22 |
class ProcessFormError(RequestError): |
a357d4147eee
[forms] work-in-progress, big editcontroller refactoring: let fields/widgets process posted data
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
23 |
"""raised when posted data can't be processed by the corresponding field |
a357d4147eee
[forms] work-in-progress, big editcontroller refactoring: let fields/widgets process posted data
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
24 |
""" |
a357d4147eee
[forms] work-in-progress, big editcontroller refactoring: let fields/widgets process posted data
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
25 |
|
0 | 26 |
class NotFound(RequestError): |
27 |
"""raised when a 404 error should be returned""" |
|
28 |
||
29 |
class Redirect(PublishException): |
|
30 |
"""raised to redirect the http request""" |
|
31 |
def __init__(self, location): |
|
32 |
self.location = location |
|
33 |
||
34 |
class DirectResponse(Exception): |
|
35 |
def __init__(self, response): |
|
36 |
self.response = response |
|
37 |
||
38 |
class StatusResponse(Exception): |
|
39 |
def __init__(self, status, content=''): |
|
40 |
self.status = int(status) |
|
41 |
self.content = content |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
320
diff
changeset
|
42 |
|
0 | 43 |
class ExplicitLogin(AuthenticationError): |
44 |
"""raised when a bad connection id is given or when an attempt to establish |
|
45 |
a connection failed""" |
|
46 |
||
47 |
class InvalidSession(CubicWebException): |
|
48 |
"""raised when a session id is found but associated session is not found or |
|
49 |
invalid |
|
50 |
""" |
|
51 |
||
52 |
class RemoteCallFailed(RequestError): |
|
53 |
"""raised when a json remote call fails |
|
54 |
""" |
|
55 |
def __init__(self, reason=''): |
|
320 | 56 |
#super(RequestError, self).__init__() # XXX require py >= 2.5 |
57 |
RequestError.__init__(self) |
|
0 | 58 |
self.reason = reason |
59 |
||
60 |
def dumps(self): |
|
61 |
import simplejson |
|
62 |
return simplejson.dumps({'reason': self.reason}) |