author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 28 Apr 2010 12:14:22 +0200 | |
changeset 5423 | e15abfdcce38 |
parent 5274 | 16461f675734 |
parent 5421 | 8167de96c523 |
child 5426 | 0d4853a6e5ee |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5273
diff
changeset
|
1 |
# 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:
5273
diff
changeset
|
2 |
# 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:
5273
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5273
diff
changeset
|
4 |
# 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:
5273
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5273
diff
changeset
|
6 |
# 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:
5273
diff
changeset
|
7 |
# 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:
5273
diff
changeset
|
8 |
# 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:
5273
diff
changeset
|
9 |
# 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:
5273
diff
changeset
|
10 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5273
diff
changeset
|
11 |
# logilab-common is distributed in the hope that it will be useful, but WITHOUT |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5273
diff
changeset
|
12 |
# 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:
5273
diff
changeset
|
13 |
# 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:
5273
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5273
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5273
diff
changeset
|
16 |
# 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:
5273
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
0 | 18 |
"""Exceptions shared by different cubicweb packages. |
19 |
||
20 |
||
21 |
""" |
|
22 |
__docformat__ = "restructuredtext en" |
|
23 |
||
24 |
from yams import ValidationError |
|
25 |
||
26 |
# abstract exceptions ######################################################### |
|
27 |
||
28 |
class CubicWebException(Exception): |
|
29 |
"""base class for cubicweb server exception""" |
|
30 |
msg = "" |
|
31 |
def __str__(self): |
|
32 |
if self.msg: |
|
33 |
if self.args: |
|
34 |
return self.msg % tuple(self.args) |
|
35 |
return self.msg |
|
4270
189e4f5279e9
unicode(arg) else we may get some encoding exception
alex & cheb
parents:
4212
diff
changeset
|
36 |
return ' '.join(unicode(arg) for arg in self.args) |
0 | 37 |
|
38 |
||
39 |
class ConfigurationError(CubicWebException): |
|
40 |
"""a misconfiguration error""" |
|
41 |
||
42 |
class InternalError(CubicWebException): |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
43 |
"""base class for exceptions which should not occurs""" |
0 | 44 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
45 |
class SecurityError(CubicWebException): |
0 | 46 |
"""base class for cubicweb server security exception""" |
47 |
||
48 |
class RepositoryError(CubicWebException): |
|
49 |
"""base class for repository exceptions""" |
|
50 |
||
51 |
class SourceException(CubicWebException): |
|
52 |
"""base class for source exceptions""" |
|
53 |
||
54 |
class CubicWebRuntimeError(CubicWebException): |
|
55 |
"""base class for runtime exceptions""" |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
56 |
|
0 | 57 |
# repository exceptions ####################################################### |
58 |
||
59 |
class ConnectionError(RepositoryError): |
|
60 |
"""raised when a bad connection id is given or when an attempt to establish |
|
5032 | 61 |
a connection failed |
62 |
""" |
|
0 | 63 |
|
64 |
class AuthenticationError(ConnectionError): |
|
5032 | 65 |
"""raised when when an attempt to establish a connection failed do to wrong |
66 |
connection information (login / password or other authentication token) |
|
4911
898c35be5873
#750055: make it easier to change post logout url
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4270
diff
changeset
|
67 |
""" |
0 | 68 |
|
69 |
class BadConnectionId(ConnectionError): |
|
5032 | 70 |
"""raised when a bad connection id is given""" |
0 | 71 |
|
72 |
class UnknownEid(RepositoryError): |
|
73 |
"""the eid is not defined in the system tables""" |
|
74 |
msg = 'No entity with eid %s in the repository' |
|
75 |
||
76 |
class ETypeNotSupportedBySources(RepositoryError, InternalError): |
|
77 |
"""no source support an entity type""" |
|
78 |
msg = 'No source supports %r entity\'s type' |
|
79 |
||
3042
d2455badf7fb
[multi-sources] enhance relation'source detection to avoid inconsistency
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2850
diff
changeset
|
80 |
class MultiSourcesError(RepositoryError, InternalError): |
d2455badf7fb
[multi-sources] enhance relation'source detection to avoid inconsistency
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2850
diff
changeset
|
81 |
"""usually due to bad multisources configuration or rql query""" |
0 | 82 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
83 |
|
0 | 84 |
# security exceptions ######################################################### |
85 |
||
86 |
class Unauthorized(SecurityError): |
|
87 |
"""raised when a user tries to perform an action without sufficient |
|
88 |
credentials |
|
89 |
""" |
|
90 |
msg = 'You are not allowed to perform this operation' |
|
91 |
msg1 = 'You are not allowed to perform %s operation on %s' |
|
92 |
var = None |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
93 |
|
0 | 94 |
def __str__(self): |
95 |
try: |
|
96 |
if self.args and len(self.args) == 2: |
|
97 |
return self.msg1 % self.args |
|
98 |
if self.args: |
|
99 |
return ' '.join(self.args) |
|
100 |
return self.msg |
|
101 |
except Exception, ex: |
|
102 |
return str(ex) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
103 |
|
0 | 104 |
# source exceptions ########################################################### |
105 |
||
106 |
class EidNotInSource(SourceException): |
|
107 |
"""trying to access an object with a particular eid from a particular |
|
108 |
source has failed |
|
109 |
""" |
|
110 |
msg = 'No entity with eid %s in %s' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
111 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
112 |
|
0 | 113 |
# registry exceptions ######################################################### |
114 |
||
115 |
class RegistryException(CubicWebException): |
|
116 |
"""raised when an unregistered view is called""" |
|
117 |
||
118 |
class RegistryNotFound(RegistryException): |
|
119 |
"""raised when an unknown registry is requested |
|
120 |
||
121 |
this is usually a programming/typo error... |
|
122 |
""" |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
123 |
|
0 | 124 |
class ObjectNotFound(RegistryException): |
125 |
"""raised when an unregistered object is requested |
|
126 |
||
127 |
this may be a programming/typo or a misconfiguration error |
|
128 |
""" |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
129 |
|
0 | 130 |
class NoSelectableObject(RegistryException): |
131 |
"""some views with the given vid have been found but no |
|
3144
a5deac822a13
Bugfix: message was not written in english
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2850
diff
changeset
|
132 |
one is applicable to the result set |
0 | 133 |
""" |
134 |
||
135 |
class UnknownProperty(RegistryException): |
|
136 |
"""property found in database but unknown in registry""" |
|
137 |
||
2651
3ad936634d2a
[registry] when a source file is changed, reset and reload the whole registry
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
138 |
|
0 | 139 |
# query exception ############################################################# |
140 |
||
141 |
class QueryError(CubicWebRuntimeError): |
|
142 |
"""a query try to do something it shouldn't""" |
|
143 |
||
144 |
class NotAnEntity(CubicWebRuntimeError): |
|
145 |
"""raised when get_entity is called for a column which doesn't contain |
|
146 |
a non final entity |
|
147 |
""" |
|
148 |
||
149 |
# tools exceptions ############################################################ |
|
150 |
||
151 |
class ExecutionError(Exception): |
|
152 |
"""server execution control error (already started, not running...)""" |
|
153 |
||
154 |
# pylint: disable-msg=W0611 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
155 |
from logilab.common.clcommands import BadCommandUsage |