Remove usage of cnx.ensure_cnx_set context manager
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 20 Jul 2016 09:09:34 +0200
changeset 11429 6a9a9ea1e9b9
parent 11428 7995ae2d74be
child 11430 1ea5ba74a13c
Remove usage of cnx.ensure_cnx_set context manager It has been deprecated since 3.21, no reason to keep using it internally.
cubicweb/dataimport/test/test_stores.py
cubicweb/server/schemaserial.py
cubicweb/server/sources/native.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)
 
 
--- 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")
--- 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):