author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 26 Apr 2010 16:31:46 +0200 | |
changeset 5408 | 120db445c179 |
parent 5385 | b6e250dd7a7d |
parent 5389 | 809d3b5b3d31 |
child 5423 | e15abfdcce38 |
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 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=''): |
|
5186
f3c2cb460ad9
[doc] note on pytestconf, fixlets
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
4252
diff
changeset
|
52 |
super(RequestError, self).__init__() |
0 | 53 |
self.reason = reason |
54 |
||
55 |
def dumps(self): |
|
5389
809d3b5b3d31
[python2.6] careful: json-py provides a json package. We don't want that.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5377
diff
changeset
|
56 |
from cubicweb.web import json |
809d3b5b3d31
[python2.6] careful: json-py provides a json package. We don't want that.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5377
diff
changeset
|
57 |
return json.dumps({'reason': self.reason}) |
5223
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5186
diff
changeset
|
58 |
|
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5186
diff
changeset
|
59 |
class LogOut(PublishException): |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5186
diff
changeset
|
60 |
"""raised to ask for deauthentication of a logged in user""" |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5186
diff
changeset
|
61 |
def __init__(self, url): |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5186
diff
changeset
|
62 |
super(LogOut, self).__init__() |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5186
diff
changeset
|
63 |
self.url = url |