author | Laurent Peuch <cortex@worlddomination.be> |
Fri, 27 Sep 2019 06:20:39 +0200 | |
changeset 12769 | a61e0fe17a69 |
parent 12614 | 8ac9ac8d9143 |
permissions | -rw-r--r-- |
9375
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
1 |
# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
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
|
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 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# 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:
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/>. |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6491
diff
changeset
|
18 |
"""Exceptions shared by different cubicweb packages.""" |
0 | 19 |
|
11767
432f87a63057
flake8 and all
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11129
diff
changeset
|
20 |
|
9375
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
21 |
from logilab.common.decorators import cachedproperty |
12613
703a263dd618
Fix flake8 errors/warnings about import in cubicweb/_exceptions.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12612
diff
changeset
|
22 |
from logilab.common.registry import RegistryException |
9375
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
23 |
|
12612
f758bc424dc9
add comment and # noqa on used import
Laurent Peuch <cortex@worlddomination.be>
parents:
12611
diff
changeset
|
24 |
from yams import ValidationError # noqa: F401 |
0 | 25 |
|
26 |
# abstract exceptions ######################################################### |
|
27 |
||
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
28 |
|
0 | 29 |
class CubicWebException(Exception): |
30 |
"""base class for cubicweb server exception""" |
|
31 |
msg = "" |
|
12567
26744ad37953
Drop python2 support
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12508
diff
changeset
|
32 |
|
26744ad37953
Drop python2 support
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12508
diff
changeset
|
33 |
def __str__(self): |
0 | 34 |
if self.msg: |
35 |
if self.args: |
|
36 |
return self.msg % tuple(self.args) |
|
8265
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
37 |
else: |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
38 |
return self.msg |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
39 |
else: |
12567
26744ad37953
Drop python2 support
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12508
diff
changeset
|
40 |
return u' '.join(str(arg) for arg in self.args) |
0 | 41 |
|
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
42 |
|
0 | 43 |
class ConfigurationError(CubicWebException): |
44 |
"""a misconfiguration error""" |
|
45 |
||
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
46 |
|
0 | 47 |
class InternalError(CubicWebException): |
10829
550c2d27339f
fix typos and indentation in docstrings/docs
Jérôme Roy <jerome.roy@logilab.fr>
parents:
10703
diff
changeset
|
48 |
"""base class for exceptions which should not occur""" |
0 | 49 |
|
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
50 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
51 |
class SecurityError(CubicWebException): |
10829
550c2d27339f
fix typos and indentation in docstrings/docs
Jérôme Roy <jerome.roy@logilab.fr>
parents:
10703
diff
changeset
|
52 |
"""base class for cubicweb server security exceptions""" |
0 | 53 |
|
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
54 |
|
0 | 55 |
class RepositoryError(CubicWebException): |
56 |
"""base class for repository exceptions""" |
|
57 |
||
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
58 |
|
0 | 59 |
class SourceException(CubicWebException): |
60 |
"""base class for source exceptions""" |
|
61 |
||
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
62 |
|
0 | 63 |
class CubicWebRuntimeError(CubicWebException): |
64 |
"""base class for runtime exceptions""" |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
65 |
|
0 | 66 |
# repository exceptions ####################################################### |
67 |
||
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
68 |
|
0 | 69 |
class ConnectionError(RepositoryError): |
70 |
"""raised when a bad connection id is given or when an attempt to establish |
|
5032 | 71 |
a connection failed |
72 |
""" |
|
0 | 73 |
|
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
74 |
|
0 | 75 |
class AuthenticationError(ConnectionError): |
9175
a7412e884d7b
fix typos in docstring, doc and comments
Julien Cristau <julien.cristau@logilab.fr>
parents:
8695
diff
changeset
|
76 |
"""raised when an attempt to establish a connection failed due to wrong |
5032 | 77 |
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
|
78 |
""" |
0 | 79 |
|
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
80 |
|
0 | 81 |
class BadConnectionId(ConnectionError): |
5032 | 82 |
"""raised when a bad connection id is given""" |
0 | 83 |
|
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
84 |
|
0 | 85 |
class UnknownEid(RepositoryError): |
86 |
"""the eid is not defined in the system tables""" |
|
87 |
msg = 'No entity with eid %s in the repository' |
|
88 |
||
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
89 |
|
6211
e9d125fd1465
nicer error reporting for unique together constraints
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5426
diff
changeset
|
90 |
class UniqueTogetherError(RepositoryError): |
e9d125fd1465
nicer error reporting for unique together constraints
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5426
diff
changeset
|
91 |
"""raised when a unique_together constraint caused an IntegrityError""" |
12607
3bf9002de48e
[autopep8] E301 - Add missing blank line
Laurent Peuch <cortex@worlddomination.be>
parents:
12567
diff
changeset
|
92 |
|
9375
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
93 |
def __init__(self, session, **kwargs): |
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
94 |
self.session = session |
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
95 |
assert 'rtypes' in kwargs or 'cstrname' in kwargs |
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
96 |
self.kwargs = kwargs |
10320
facbb38c4c1a
[exceptions] avoid calling UniqueExceptionError.rtypes after closing the session
Julien Cristau <julien.cristau@logilab.fr>
parents:
10280
diff
changeset
|
97 |
# fill cache while the session is open |
facbb38c4c1a
[exceptions] avoid calling UniqueExceptionError.rtypes after closing the session
Julien Cristau <julien.cristau@logilab.fr>
parents:
10280
diff
changeset
|
98 |
self.rtypes |
9375
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
99 |
|
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
100 |
@cachedproperty |
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
101 |
def rtypes(self): |
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
102 |
if 'rtypes' in self.kwargs: |
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
103 |
return self.kwargs['rtypes'] |
12567
26744ad37953
Drop python2 support
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12508
diff
changeset
|
104 |
cstrname = str(self.kwargs['cstrname']) |
9375
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
105 |
cstr = self.session.find('CWUniqueTogetherConstraint', name=cstrname).one() |
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
106 |
return sorted(rtype.name for rtype in cstr.relations) |
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9347
diff
changeset
|
107 |
|
8265
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
108 |
|
10446
1e6655cff5ab
add IUserFriendlyError adapter for violation of check constraints
Julien Cristau <julien.cristau@logilab.fr>
parents:
10320
diff
changeset
|
109 |
class ViolatedConstraint(RepositoryError): |
12614
8ac9ac8d9143
[mod] make ViolatedConstraint actually display useful information
Laurent Peuch <cortex@worlddomination.be>
parents:
12613
diff
changeset
|
110 |
def __init__(self, cnx, cstrname, query): |
10446
1e6655cff5ab
add IUserFriendlyError adapter for violation of check constraints
Julien Cristau <julien.cristau@logilab.fr>
parents:
10320
diff
changeset
|
111 |
self.cnx = cnx |
1e6655cff5ab
add IUserFriendlyError adapter for violation of check constraints
Julien Cristau <julien.cristau@logilab.fr>
parents:
10320
diff
changeset
|
112 |
self.cstrname = cstrname |
12614
8ac9ac8d9143
[mod] make ViolatedConstraint actually display useful information
Laurent Peuch <cortex@worlddomination.be>
parents:
12613
diff
changeset
|
113 |
message = ( |
8ac9ac8d9143
[mod] make ViolatedConstraint actually display useful information
Laurent Peuch <cortex@worlddomination.be>
parents:
12613
diff
changeset
|
114 |
"constraint '%s' is being violated by the query '%s'. " |
8ac9ac8d9143
[mod] make ViolatedConstraint actually display useful information
Laurent Peuch <cortex@worlddomination.be>
parents:
12613
diff
changeset
|
115 |
"You can run the inverted constraint on the database to list the problematic rows." |
8ac9ac8d9143
[mod] make ViolatedConstraint actually display useful information
Laurent Peuch <cortex@worlddomination.be>
parents:
12613
diff
changeset
|
116 |
) % (cstrname, query) |
8ac9ac8d9143
[mod] make ViolatedConstraint actually display useful information
Laurent Peuch <cortex@worlddomination.be>
parents:
12613
diff
changeset
|
117 |
super(ViolatedConstraint, self).__init__(message) |
10446
1e6655cff5ab
add IUserFriendlyError adapter for violation of check constraints
Julien Cristau <julien.cristau@logilab.fr>
parents:
10320
diff
changeset
|
118 |
|
1e6655cff5ab
add IUserFriendlyError adapter for violation of check constraints
Julien Cristau <julien.cristau@logilab.fr>
parents:
10320
diff
changeset
|
119 |
|
0 | 120 |
# security exceptions ######################################################### |
121 |
||
122 |
class Unauthorized(SecurityError): |
|
123 |
"""raised when a user tries to perform an action without sufficient |
|
124 |
credentials |
|
125 |
""" |
|
11103
d1798710f922
[exceptions] fix string conversion for Unauthorized exception
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
10907
diff
changeset
|
126 |
msg = u'You are not allowed to perform this operation' |
d1798710f922
[exceptions] fix string conversion for Unauthorized exception
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
10907
diff
changeset
|
127 |
msg1 = u'You are not allowed to perform %s operation on %s' |
0 | 128 |
var = None |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
129 |
|
12567
26744ad37953
Drop python2 support
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12508
diff
changeset
|
130 |
def __str__(self): |
0 | 131 |
try: |
132 |
if self.args and len(self.args) == 2: |
|
133 |
return self.msg1 % self.args |
|
134 |
if self.args: |
|
11103
d1798710f922
[exceptions] fix string conversion for Unauthorized exception
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
10907
diff
changeset
|
135 |
return u' '.join(self.args) |
0 | 136 |
return self.msg |
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8609
diff
changeset
|
137 |
except Exception as ex: |
12567
26744ad37953
Drop python2 support
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12508
diff
changeset
|
138 |
return str(ex) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
139 |
|
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
140 |
|
8602
d066ba3bb07d
[web] add a Forbidden exception
David Douard <david.douard@logilab.fr>
parents:
8265
diff
changeset
|
141 |
class Forbidden(SecurityError): |
d066ba3bb07d
[web] add a Forbidden exception
David Douard <david.douard@logilab.fr>
parents:
8265
diff
changeset
|
142 |
"""raised when a user tries to perform a forbidden action |
d066ba3bb07d
[web] add a Forbidden exception
David Douard <david.douard@logilab.fr>
parents:
8265
diff
changeset
|
143 |
""" |
d066ba3bb07d
[web] add a Forbidden exception
David Douard <david.douard@logilab.fr>
parents:
8265
diff
changeset
|
144 |
|
0 | 145 |
# source exceptions ########################################################### |
146 |
||
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
147 |
|
0 | 148 |
class EidNotInSource(SourceException): |
149 |
"""trying to access an object with a particular eid from a particular |
|
150 |
source has failed |
|
151 |
""" |
|
152 |
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
|
153 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1155
diff
changeset
|
154 |
|
0 | 155 |
# registry exceptions ######################################################### |
156 |
||
157 |
class UnknownProperty(RegistryException): |
|
158 |
"""property found in database but unknown in registry""" |
|
159 |
||
160 |
# query exception ############################################################# |
|
161 |
||
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
162 |
|
0 | 163 |
class QueryError(CubicWebRuntimeError): |
164 |
"""a query try to do something it shouldn't""" |
|
165 |
||
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
166 |
|
0 | 167 |
class NotAnEntity(CubicWebRuntimeError): |
168 |
"""raised when get_entity is called for a column which doesn't contain |
|
169 |
a non final entity |
|
170 |
""" |
|
171 |
||
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
172 |
|
9347
bd841d6ae723
[rset] New method: ResultSet.one()
Christophe de Vienne <cdevienne@gmail.com>
parents:
9175
diff
changeset
|
173 |
class MultipleResultsError(CubicWebRuntimeError): |
bd841d6ae723
[rset] New method: ResultSet.one()
Christophe de Vienne <cdevienne@gmail.com>
parents:
9175
diff
changeset
|
174 |
"""raised when ResultSet.one() is called on a resultset with multiple rows |
bd841d6ae723
[rset] New method: ResultSet.one()
Christophe de Vienne <cdevienne@gmail.com>
parents:
9175
diff
changeset
|
175 |
of multiple columns. |
bd841d6ae723
[rset] New method: ResultSet.one()
Christophe de Vienne <cdevienne@gmail.com>
parents:
9175
diff
changeset
|
176 |
""" |
bd841d6ae723
[rset] New method: ResultSet.one()
Christophe de Vienne <cdevienne@gmail.com>
parents:
9175
diff
changeset
|
177 |
|
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
178 |
|
9347
bd841d6ae723
[rset] New method: ResultSet.one()
Christophe de Vienne <cdevienne@gmail.com>
parents:
9175
diff
changeset
|
179 |
class NoResultError(CubicWebRuntimeError): |
bd841d6ae723
[rset] New method: ResultSet.one()
Christophe de Vienne <cdevienne@gmail.com>
parents:
9175
diff
changeset
|
180 |
"""raised when no result is found but at least one is expected. |
bd841d6ae723
[rset] New method: ResultSet.one()
Christophe de Vienne <cdevienne@gmail.com>
parents:
9175
diff
changeset
|
181 |
""" |
bd841d6ae723
[rset] New method: ResultSet.one()
Christophe de Vienne <cdevienne@gmail.com>
parents:
9175
diff
changeset
|
182 |
|
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
183 |
|
8265
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
184 |
class UndoTransactionException(QueryError): |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
185 |
"""Raised when undoing a transaction could not be performed completely. |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
186 |
|
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
187 |
Note that : |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
188 |
1) the partial undo operation might be acceptable |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
189 |
depending upon the final application |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
190 |
|
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
191 |
2) the undo operation can also fail with a `ValidationError` in |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
192 |
cases where the undoing breaks integrity constraints checked |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
193 |
immediately. |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
194 |
|
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
195 |
3) It might be that neither of those exception is raised but a |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
196 |
subsequent `commit` might raise a `ValidationError` in cases |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
197 |
where the undoing breaks integrity constraints checked at |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
198 |
commit time. |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
199 |
|
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
200 |
:type txuuix: int |
10903
da30851f9706
spelling: *aly → *ally
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10829
diff
changeset
|
201 |
:param txuuid: Unique identifier of the partially undone transaction |
8265
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
202 |
|
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
203 |
:type errors: list |
9517
3338b2205ea3
Typo in comments and error messages
Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
parents:
9375
diff
changeset
|
204 |
:param errors: List of errors occurred during undoing |
8265
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
205 |
""" |
9517
3338b2205ea3
Typo in comments and error messages
Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
parents:
9375
diff
changeset
|
206 |
msg = u"The following error(s) occurred while undoing transaction #%d : %s" |
8265
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
207 |
|
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
208 |
def __init__(self, txuuid, errors): |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
209 |
super(UndoTransactionException, self).__init__(txuuid, errors) |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
210 |
self.txuuid = txuuid |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
211 |
self.errors = errors |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8190
diff
changeset
|
212 |
|
0 | 213 |
# tools exceptions ############################################################ |
214 |
||
12608
6b2a9f288956
[autopep8] E302 - Add missing 2 blank lines
Laurent Peuch <cortex@worlddomination.be>
parents:
12607
diff
changeset
|
215 |
|
0 | 216 |
class ExecutionError(Exception): |
217 |
"""server execution control error (already started, not running...)""" |
|
218 |
||
12610
27af91c2b3e9
[autopep8] E305 - Expected 2 blank lines after end of function or class
Laurent Peuch <cortex@worlddomination.be>
parents:
12609
diff
changeset
|
219 |
|
6491
ee9a10b6620e
pylint option update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6347
diff
changeset
|
220 |
# pylint: disable=W0611 |
12613
703a263dd618
Fix flake8 errors/warnings about import in cubicweb/_exceptions.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12612
diff
changeset
|
221 |
from logilab.common.clcommands import BadCommandUsage # noqa: E402, F401 |