# HG changeset patch # User Julien Cristau # Date 1410768367 -7200 # Node ID 65bb21409292fefad330f8368d628bdcfa0cbfb5 # Parent c9f1111e0ee84abc5da6781476709feccc1698fe [server] hold connection to the db in tx_actions We can be called without a cnxset (e.g. from repoapi). diff -r c9f1111e0ee8 -r 65bb21409292 server/sources/native.py --- a/server/sources/native.py Mon Sep 15 17:23:22 2014 +0200 +++ b/server/sources/native.py Mon Sep 15 10:06:07 2014 +0200 @@ -1017,14 +1017,16 @@ sql = self.sqlgen.select('tx_entity_actions', restr, ('txa_action', 'txa_public', 'txa_order', 'etype', 'eid', 'changes')) - cu = self.doexec(cnx, sql, restr) - actions = [tx.EntityAction(a,p,o,et,e,c and loads(self.binary_to_str(c))) - for a,p,o,et,e,c in cu.fetchall()] + with cnx.ensure_cnx_set: + cu = self.doexec(cnx, sql, restr) + actions = [tx.EntityAction(a,p,o,et,e,c and loads(self.binary_to_str(c))) + for a,p,o,et,e,c in cu.fetchall()] sql = self.sqlgen.select('tx_relation_actions', restr, ('txa_action', 'txa_public', 'txa_order', 'rtype', 'eid_from', 'eid_to')) - cu = self.doexec(cnx, sql, restr) - actions += [tx.RelationAction(*args) for args in cu.fetchall()] + with cnx.ensure_cnx_set: + cu = self.doexec(cnx, sql, restr) + actions += [tx.RelationAction(*args) for args in cu.fetchall()] return sorted(actions, key=lambda x: x.order) def undo_transaction(self, cnx, txuuid): diff -r c9f1111e0ee8 -r 65bb21409292 server/test/unittest_undo.py --- a/server/test/unittest_undo.py Mon Sep 15 17:23:22 2014 +0200 +++ b/server/test/unittest_undo.py Mon Sep 15 10:06:07 2014 +0200 @@ -75,6 +75,8 @@ self.assertTrue(self.txuuid) # test transaction api with self.admin_access.client_cnx() as cnx: + tx_actions = cnx.transaction_actions(self.txuuid) + self.assertEqual(len(tx_actions), 2, tx_actions) self.assertRaises(NoSuchTransaction, cnx.transaction_info, 'hop') self.assertRaises(NoSuchTransaction,