author | Julien Jehannet <julien.jehannet@logilab.fr> |
Wed, 07 Sep 2011 11:37:41 +0200 | |
branch | stable |
changeset 7767 | 07c74f5585d1 |
parent 7384 | 69aa88765db5 |
child 8312 | 6c2119509fac |
permissions | -rw-r--r-- |
6491
ee9a10b6620e
pylint option update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
1 |
# pylint: disable=W0401,W0614 |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
2 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
3 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
4 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
5 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
6 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
7 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
8 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
9 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
10 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
11 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
12 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
13 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
14 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
15 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
16 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
17 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
18 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5940
0e3ae19b181a
[uilib] refactor json_dumps code organization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
19 |
"""exceptions used in the core of the CubicWeb web application""" |
0 | 20 |
|
21 |
__docformat__ = "restructuredtext en" |
|
22 |
||
23 |
from cubicweb._exceptions import * |
|
5940
0e3ae19b181a
[uilib] refactor json_dumps code organization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
24 |
from cubicweb.utils import json_dumps |
0 | 25 |
|
26 |
class PublishException(CubicWebException): |
|
27 |
"""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
|
28 |
|
0 | 29 |
class RequestError(PublishException): |
30 |
"""raised when a request can't be served because of a bad input""" |
|
31 |
||
32 |
class NothingToEdit(RequestError): |
|
33 |
"""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
|
34 |
|
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
|
35 |
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
|
36 |
"""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
|
37 |
""" |
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
|
38 |
|
0 | 39 |
class NotFound(RequestError): |
40 |
"""raised when a 404 error should be returned""" |
|
41 |
||
42 |
class Redirect(PublishException): |
|
43 |
"""raised to redirect the http request""" |
|
44 |
def __init__(self, location): |
|
45 |
self.location = location |
|
46 |
||
47 |
class DirectResponse(Exception): |
|
48 |
def __init__(self, response): |
|
49 |
self.response = response |
|
50 |
||
51 |
class StatusResponse(Exception): |
|
52 |
def __init__(self, status, content=''): |
|
53 |
self.status = int(status) |
|
54 |
self.content = content |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
320
diff
changeset
|
55 |
|
7384
69aa88765db5
[http] Make a better __repr__ for Status responce exception.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6807
diff
changeset
|
56 |
def __repr__(self): |
69aa88765db5
[http] Make a better __repr__ for Status responce exception.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6807
diff
changeset
|
57 |
return '%s(%r, %r)' % (self.__class__.__name__, self.status, self.content) |
69aa88765db5
[http] Make a better __repr__ for Status responce exception.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6807
diff
changeset
|
58 |
|
0 | 59 |
class InvalidSession(CubicWebException): |
60 |
"""raised when a session id is found but associated session is not found or |
|
61 |
invalid |
|
62 |
""" |
|
63 |
||
64 |
class RemoteCallFailed(RequestError): |
|
65 |
"""raised when a json remote call fails |
|
66 |
""" |
|
67 |
def __init__(self, reason=''): |
|
6807
7330d1fa02dd
[cleanup] pylint detected error (among a ton of false positives due to the dynamic nature of cubicweb's code...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6491
diff
changeset
|
68 |
super(RemoteCallFailed, self).__init__() |
0 | 69 |
self.reason = reason |
70 |
||
71 |
def dumps(self): |
|
5940
0e3ae19b181a
[uilib] refactor json_dumps code organization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
72 |
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
|
73 |
|
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
|
74 |
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
|
75 |
"""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
|
76 |
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
|
77 |
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
|
78 |
self.url = url |