transaction.py
changeset 8266 704dda5c07f7
parent 8265 9747ab9230ad
child 9052 4cba5f2cd57b
--- a/transaction.py	Mon Feb 27 09:43:15 2012 +0100
+++ b/transaction.py	Mon Feb 27 09:45:48 2012 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -21,7 +21,6 @@
 This module is in the cubicweb package and not in cubicweb.server because those
 objects should be accessible to client through pyro, where the cubicweb.server
 package may not be installed.
-
 """
 __docformat__ = "restructuredtext en"
 _ = unicode
@@ -86,6 +85,11 @@
     def label(self):
         return ACTION_LABELS[self.action]
 
+    @property
+    def ertype(self):
+        """ Return the entity or relation type this action is related to"""
+        raise NotImplementedError(self)
+
 
 class EntityAction(AbstractAction):
     def __init__(self, action, public, order, etype, eid, changes):
@@ -99,6 +103,11 @@
             self.label, self.eid, self.changes,
             self.public and 'dbapi' or 'hook')
 
+    @property
+    def ertype(self):
+        """ Return the entity or relation type this action is related to"""
+        return self.etype
+
 
 class RelationAction(AbstractAction):
     def __init__(self, action, public, order, rtype, eidfrom, eidto):
@@ -111,3 +120,8 @@
         return '<%s: %s %s %s (%s)>' % (
             self.label, self.eid_from, self.rtype, self.eid_to,
             self.public and 'dbapi' or 'hook')
+
+    @property
+    def ertype(self):
+        """ Return the entity or relation type this action is related to"""
+        return self.rtype