equal
deleted
inserted
replaced
1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
19 |
19 |
20 |
20 |
21 This module is in the cubicweb package and not in cubicweb.server because those |
21 This module is in the cubicweb package and not in cubicweb.server because those |
22 objects should be accessible to client through pyro, where the cubicweb.server |
22 objects should be accessible to client through pyro, where the cubicweb.server |
23 package may not be installed. |
23 package may not be installed. |
24 |
|
25 """ |
24 """ |
26 __docformat__ = "restructuredtext en" |
25 __docformat__ = "restructuredtext en" |
27 _ = unicode |
26 _ = unicode |
28 |
27 |
29 from cubicweb import RepositoryError |
28 from cubicweb import RepositoryError |
84 |
83 |
85 @property |
84 @property |
86 def label(self): |
85 def label(self): |
87 return ACTION_LABELS[self.action] |
86 return ACTION_LABELS[self.action] |
88 |
87 |
|
88 @property |
|
89 def ertype(self): |
|
90 """ Return the entity or relation type this action is related to""" |
|
91 raise NotImplementedError(self) |
|
92 |
89 |
93 |
90 class EntityAction(AbstractAction): |
94 class EntityAction(AbstractAction): |
91 def __init__(self, action, public, order, etype, eid, changes): |
95 def __init__(self, action, public, order, etype, eid, changes): |
92 AbstractAction.__init__(self, action, public, order) |
96 AbstractAction.__init__(self, action, public, order) |
93 self.etype = etype |
97 self.etype = etype |
97 def __repr__(self): |
101 def __repr__(self): |
98 return '<%s: %s %s (%s)>' % ( |
102 return '<%s: %s %s (%s)>' % ( |
99 self.label, self.eid, self.changes, |
103 self.label, self.eid, self.changes, |
100 self.public and 'dbapi' or 'hook') |
104 self.public and 'dbapi' or 'hook') |
101 |
105 |
|
106 @property |
|
107 def ertype(self): |
|
108 """ Return the entity or relation type this action is related to""" |
|
109 return self.etype |
|
110 |
102 |
111 |
103 class RelationAction(AbstractAction): |
112 class RelationAction(AbstractAction): |
104 def __init__(self, action, public, order, rtype, eidfrom, eidto): |
113 def __init__(self, action, public, order, rtype, eidfrom, eidto): |
105 AbstractAction.__init__(self, action, public, order) |
114 AbstractAction.__init__(self, action, public, order) |
106 self.rtype = rtype |
115 self.rtype = rtype |
109 |
118 |
110 def __repr__(self): |
119 def __repr__(self): |
111 return '<%s: %s %s %s (%s)>' % ( |
120 return '<%s: %s %s %s (%s)>' % ( |
112 self.label, self.eid_from, self.rtype, self.eid_to, |
121 self.label, self.eid_from, self.rtype, self.eid_to, |
113 self.public and 'dbapi' or 'hook') |
122 self.public and 'dbapi' or 'hook') |
|
123 |
|
124 @property |
|
125 def ertype(self): |
|
126 """ Return the entity or relation type this action is related to""" |
|
127 return self.rtype |