[session] gather close_cnx with get_cnx and set_cnx
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Wed, 26 Jun 2013 11:39:01 +0200
changeset 9102 c9ed52e53526
parent 9101 e6d1df619949
child 9103 b5c6d6aaa2bf
[session] gather close_cnx with get_cnx and set_cnx They do the same kind of operation and deserve to be grouped together.
server/session.py
--- a/server/session.py	Thu Jun 27 11:13:18 2013 +0200
+++ b/server/session.py	Wed Jun 26 11:39:01 2013 +0200
@@ -1304,6 +1304,14 @@
                 self._cnxs[cnxid] = cnx
         return cnx
 
+    def close_cnx(self, cnxid):
+        """Close a Connection related to a session"""
+        cnx = self._cnxs.get(cnxid, None)
+        if cnx is not None:
+            cnx.free_cnxset(ignoremode=True)
+            self._clear_thread_storage(cnx)
+            self._clear_cnx_storage(cnx)
+
     def set_cnx(self, cnxid=None):
         """set the default connection of the current thread to <cnxid>
 
@@ -1489,14 +1497,6 @@
         rset.req = self
         return rset
 
-    def close_cnx(self, cnxid):
-        cnx = self._cnxs.get(cnxid, None)
-        if cnx is not None:
-            cnx.free_cnxset(ignoremode=True)
-            self._clear_thread_storage(cnx)
-            self._clear_cnx_storage(cnx)
-
-
     def _clear_thread_data(self, free_cnxset=True):
         """remove everything from the thread local storage, except connections set
         which is explicitly removed by free_cnxset, and mode which is set anyway