# HG changeset patch # User Denis Laxalde # Date 1468998574 -7200 # Node ID 6a9a9ea1e9b986f7bf1529e03e1c2becf71358f1 # Parent 7995ae2d74be432d869718244720f91aefffebdd Remove usage of cnx.ensure_cnx_set context manager It has been deprecated since 3.21, no reason to keep using it internally. diff -r 7995ae2d74be -r 6a9a9ea1e9b9 cubicweb/dataimport/test/test_stores.py --- a/cubicweb/dataimport/test/test_stores.py Fri Jun 26 10:26:00 2015 +0200 +++ b/cubicweb/dataimport/test/test_stores.py Wed Jul 20 09:09:34 2016 +0200 @@ -107,8 +107,7 @@ md = DT.datetime.now(pytz.utc) - DT.timedelta(days=1) entity, rels = metagen.base_etype_dicts('CWUser') entity.cw_edited.update(dict(modification_date=md)) - with cnx.ensure_cnx_set: - metagen.init_entity(entity) + metagen.init_entity(entity) self.assertEqual(entity.cw_edited['modification_date'], md) @@ -140,8 +139,7 @@ md = DT.datetime.now(pytz.utc) - DT.timedelta(days=1) attrs = metagen.base_etype_attrs('CWUser') attrs.update(dict(modification_date=md)) - with cnx.ensure_cnx_set: - metagen.init_entity_attrs('CWUser', 1, attrs) + metagen.init_entity_attrs('CWUser', 1, attrs) self.assertEqual(attrs['modification_date'], md) diff -r 7995ae2d74be -r 6a9a9ea1e9b9 cubicweb/server/schemaserial.py --- a/cubicweb/server/schemaserial.py Fri Jun 26 10:26:00 2015 +0200 +++ b/cubicweb/server/schemaserial.py Wed Jul 20 09:09:34 2016 +0200 @@ -93,9 +93,8 @@ dbhelper = repo.system_source.dbhelper # Computed Rtype - with cnx.ensure_cnx_set: - tables = set(t.lower() for t in dbhelper.list_tables(cnx.cnxset.cu)) - has_computed_relations = 'cw_cwcomputedrtype' in tables + tables = set(t.lower() for t in dbhelper.list_tables(cnx.cnxset.cu)) + has_computed_relations = 'cw_cwcomputedrtype' in tables # computed attribute try: cnx.system_sql("SELECT cw_formula FROM cw_CWAttribute") diff -r 7995ae2d74be -r 6a9a9ea1e9b9 cubicweb/server/sources/native.py --- a/cubicweb/server/sources/native.py Fri Jun 26 10:26:00 2015 +0200 +++ b/cubicweb/server/sources/native.py Wed Jul 20 09:09:34 2016 +0200 @@ -1048,16 +1048,14 @@ sql = self.sqlgen.select('tx_entity_actions', restr, ('txa_action', 'txa_public', 'txa_order', 'etype', 'eid', 'changes')) - with cnx.ensure_cnx_set: - cu = self.doexec(cnx, sql, restr) - actions = [tx.EntityAction(a, p, o, et, e, c and pickle.loads(self.binary_to_str(c))) - for a, p, o, et, e, c in cu.fetchall()] + cu = self.doexec(cnx, sql, restr) + actions = [tx.EntityAction(a, p, o, et, e, c and pickle.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')) - with cnx.ensure_cnx_set: - cu = self.doexec(cnx, sql, restr) - actions += [tx.RelationAction(*args) for args in cu.fetchall()] + 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):