author | Rabah Meradi <rabah.meradi@logilab.fr> |
Wed, 03 Jun 2015 17:15:08 +0200 | |
changeset 10379 | a1cc6788e9de |
parent 9052 | 4cba5f2cd57b |
child 10235 | 684215aca046 |
permissions | -rw-r--r-- |
8266
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
1 |
# copyright 2003-2012 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:
4913
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:
4913
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:
4913
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:
4913
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:
4913
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:
4913
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:
4913
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:
4913
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:
4913
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:
4913
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:
4913
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:
4913
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:
4913
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:
4913
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:
4913
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
18 |
"""undoable transaction objects. |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
19 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
20 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
21 |
This module is in the cubicweb package and not in cubicweb.server because those |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
22 |
objects should be accessible to client through pyro, where the cubicweb.server |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
23 |
package may not be installed. |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
24 |
""" |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
25 |
__docformat__ = "restructuredtext en" |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
26 |
_ = unicode |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
27 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
28 |
from cubicweb import RepositoryError |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
29 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
30 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
31 |
ACTION_LABELS = { |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
32 |
'C': _('entity creation'), |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
33 |
'U': _('entity update'), |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
34 |
'D': _('entity deletion'), |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
35 |
'A': _('relation add'), |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
36 |
'R': _('relation removal'), |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
37 |
} |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
38 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
39 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
40 |
class NoSuchTransaction(RepositoryError): |
8265
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
5426
diff
changeset
|
41 |
# Used by CubicWebException |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
5426
diff
changeset
|
42 |
msg = _("there is no transaction #%s") |
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
43 |
|
8265
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
5426
diff
changeset
|
44 |
def __init__(self, txuuid): |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
5426
diff
changeset
|
45 |
super(RepositoryError, self).__init__(txuuid) |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
5426
diff
changeset
|
46 |
self.txuuid = txuuid |
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
47 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
48 |
class Transaction(object): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
49 |
"""an undoable transaction""" |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
50 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
51 |
def __init__(self, uuid, time, ueid): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
52 |
self.uuid = uuid |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
53 |
self.datetime = time |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
54 |
self.user_eid = ueid |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
55 |
# should be set by the dbapi connection |
9052
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
56 |
self.req = None # old style |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
57 |
self.cnx = None # new style |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
58 |
|
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
59 |
def _execute(self, *args, **kwargs): |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
60 |
"""execute a query using either the req or the cnx""" |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
61 |
if self.req is None: |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
62 |
execute = self.cnx.execute |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
63 |
else: |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
64 |
execute = self.req |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
65 |
return execute(*args, **kwargs) |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
66 |
|
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
67 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
68 |
def __repr__(self): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
69 |
return '<Transaction %s by %s on %s>' % ( |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
70 |
self.uuid, self.user_eid, self.datetime) |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
71 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
72 |
def user(self): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
73 |
"""return the user entity which has done the transaction, |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
74 |
none if not found. |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
75 |
""" |
9052
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
76 |
return self._execute('Any X WHERE X eid %(x)s', |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
77 |
{'x': self.user_eid}).get_entity(0, 0) |
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
78 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
79 |
def actions_list(self, public=True): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
80 |
"""return an ordered list of action effectued during that transaction |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
81 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
82 |
if public is true, return only 'public' action, eg not ones triggered |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
83 |
under the cover by hooks. |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
84 |
""" |
9052
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
85 |
if self.req is not None: |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
86 |
cnx = self.req.cnx |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
87 |
else: |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
88 |
cnx = self.cnx |
4cba5f2cd57b
[repoapi] introduce a basic ClientConnection class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8266
diff
changeset
|
89 |
return cnx.transaction_actions(self.uuid, public) |
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
90 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
91 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
92 |
class AbstractAction(object): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
93 |
def __init__(self, action, public, order): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
94 |
self.action = action |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
95 |
self.public = public |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
96 |
self.order = order |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
97 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
98 |
@property |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
99 |
def label(self): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
100 |
return ACTION_LABELS[self.action] |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
101 |
|
8266
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
102 |
@property |
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
103 |
def ertype(self): |
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
104 |
""" Return the entity or relation type this action is related to""" |
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
105 |
raise NotImplementedError(self) |
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
106 |
|
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
107 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
108 |
class EntityAction(AbstractAction): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
109 |
def __init__(self, action, public, order, etype, eid, changes): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
110 |
AbstractAction.__init__(self, action, public, order) |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
111 |
self.etype = etype |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
112 |
self.eid = eid |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
113 |
self.changes = changes |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
114 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
115 |
def __repr__(self): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
116 |
return '<%s: %s %s (%s)>' % ( |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
117 |
self.label, self.eid, self.changes, |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
118 |
self.public and 'dbapi' or 'hook') |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
119 |
|
8266
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
120 |
@property |
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
121 |
def ertype(self): |
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
122 |
""" Return the entity or relation type this action is related to""" |
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
123 |
return self.etype |
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
124 |
|
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
125 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
126 |
class RelationAction(AbstractAction): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
127 |
def __init__(self, action, public, order, rtype, eidfrom, eidto): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
128 |
AbstractAction.__init__(self, action, public, order) |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
129 |
self.rtype = rtype |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
130 |
self.eid_from = eidfrom |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
131 |
self.eid_to = eidto |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
132 |
|
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
133 |
def __repr__(self): |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
134 |
return '<%s: %s %s %s (%s)>' % ( |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
135 |
self.label, self.eid_from, self.rtype, self.eid_to, |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff
changeset
|
136 |
self.public and 'dbapi' or 'hook') |
8266
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
137 |
|
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
138 |
@property |
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
139 |
def ertype(self): |
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
140 |
""" Return the entity or relation type this action is related to""" |
704dda5c07f7
[undo, transactions] Adds a property in the transaction API. (closes #2202953)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
141 |
return self.rtype |