author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Thu, 15 Apr 2010 10:59:49 +0200 | |
branch | stable |
changeset 5267 | 7bac6791bbc2 |
parent 5186 | f3c2cb460ad9 |
child 5223 | 6abd6e3599f4 |
child 5377 | 84d14ddfae13 |
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=''): |
|
5186
f3c2cb460ad9
[doc] note on pytestconf, fixlets
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
4252
diff
changeset
|
56 |
super(RequestError, self).__init__() |
0 | 57 |
self.reason = reason |
58 |
||
59 |
def dumps(self): |
|
60 |
import simplejson |
|
61 |
return simplejson.dumps({'reason': self.reason}) |