# HG changeset patch # User Anthony Truchet # Date 1330332348 -3600 # Node ID 704dda5c07f746822c696bb85fa726423573c881 # Parent 9747ab9230ad3d435218a99b099cc167809704a5 [undo, transactions] Adds a property in the transaction API. (closes #2202953) Required by forthcoming changes in undo_web.diff diff -r 9747ab9230ad -r 704dda5c07f7 server/test/unittest_undo.py --- a/server/test/unittest_undo.py Mon Feb 27 09:43:15 2012 +0100 +++ b/server/test/unittest_undo.py Mon Feb 27 09:45:48 2012 +0100 @@ -80,12 +80,14 @@ self.assertEqual(a1.action, 'C') self.assertEqual(a1.eid, self.toto.eid) self.assertEqual(a1.etype,'CWUser') + self.assertEqual(a1.ertype, 'CWUser') self.assertEqual(a1.changes, None) self.assertEqual(a1.public, True) self.assertEqual(a1.order, 1) a4 = actions[3] self.assertEqual(a4.action, 'A') self.assertEqual(a4.rtype, 'in_group') + self.assertEqual(a4.ertype, 'in_group') self.assertEqual(a4.eid_from, self.toto.eid) self.assertEqual(a4.eid_to, self.toto.in_group[0].eid) self.assertEqual(a4.order, 4) diff -r 9747ab9230ad -r 704dda5c07f7 transaction.py --- 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