[session] fix super call in Connection.__init__
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 16 Jul 2014 16:26:16 +0200
changeset 11200 8ddfed7a5981
parent 11199 2fe2077cc92d
child 11201 4db44a475b9b
[session] fix super call in Connection.__init__ The vile hacks in test fixtures are fixed.
cubicweb/server/session.py
cubicweb/server/test/unittest_undo.py
cubicweb/web/test/unittest_views_basecontrollers.py
--- a/cubicweb/server/session.py	Wed Jul 16 15:30:16 2014 +0200
+++ b/cubicweb/server/session.py	Wed Jul 16 16:26:16 2014 +0200
@@ -254,8 +254,7 @@
     is_repo_in_memory = True # bw compat
 
     def __init__(self, session):
-        # using super(Connection, self) confuse some test hack
-        RequestSessionBase.__init__(self, session.vreg)
+        super(Connection, self).__init__(session.repo.vreg)
         #: connection unique id
         self._open = None
         self.connectionid = '%s-%s' % (session.sessionid, uuid4().hex)
--- a/cubicweb/server/test/unittest_undo.py	Wed Jul 16 15:30:16 2014 +0200
+++ b/cubicweb/server/test/unittest_undo.py	Wed Jul 16 16:26:16 2014 +0200
@@ -21,8 +21,7 @@
 
 from cubicweb import ValidationError
 from cubicweb.devtools.testlib import CubicWebTC
-import cubicweb.server.session
-from cubicweb.server.session import Connection as OldConnection
+from cubicweb.server.session import Connection
 
 from cubicweb.server.sources.native import UndoTransactionException, _UndoException
 
@@ -42,15 +41,13 @@
         return cnx.entity_from_eid(self.totoeid)
 
     def setUp(self):
-        class Connection(OldConnection):
-            """Force undo feature to be turned on in all case"""
-            undo_actions = property(lambda tx: True, lambda x, y:None)
-        cubicweb.server.session.Connection = Connection
+        # Force undo feature to be turned on
+        Connection.undo_actions = property(lambda self: True, lambda self, v:None)
         super(UndoableTransactionTC, self).setUp()
 
     def tearDown(self):
-        cubicweb.server.session.Connection = OldConnection
         super(UndoableTransactionTC, self).tearDown()
+        del Connection.undo_actions
 
     def check_transaction_deleted(self, cnx, txuuid):
         # also check transaction actions have been properly deleted
--- a/cubicweb/web/test/unittest_views_basecontrollers.py	Wed Jul 16 15:30:16 2014 +0200
+++ b/cubicweb/web/test/unittest_views_basecontrollers.py	Wed Jul 16 16:26:16 2014 +0200
@@ -33,7 +33,7 @@
 from cubicweb.uilib import rql_for_eid
 from cubicweb.web import Redirect, RemoteCallFailed
 import cubicweb.server.session
-from cubicweb.server.session import Connection as OldConnection
+from cubicweb.server.session import Connection
 from cubicweb.web.views.autoform import get_pending_inserts, get_pending_deletes
 from cubicweb.web.views.basecontrollers import JSonController, xhtmlize, jsonize
 from cubicweb.web.views.ajaxcontroller import ajaxfunc, AjaxFunction
@@ -1013,15 +1013,13 @@
 class UndoControllerTC(CubicWebTC):
 
     def setUp(self):
-        class Connection(OldConnection):
-            """Force undo feature to be turned on in all case"""
-            undo_actions = property(lambda tx: True, lambda x, y:None)
-        cubicweb.server.session.Connection = Connection
+        # Force undo feature to be turned on
+        Connection.undo_actions = property(lambda self: True, lambda self, v:None)
         super(UndoControllerTC, self).setUp()
 
     def tearDown(self):
         super(UndoControllerTC, self).tearDown()
-        cubicweb.server.session.Connection = OldConnection
+        del Connection.undo_actions
 
     def setup_database(self):
         with self.admin_access.repo_cnx() as cnx: