server/session.py
changeset 9102 c9ed52e53526
parent 9098 5467fb901931
child 9103 b5c6d6aaa2bf
equal deleted inserted replaced
9101:e6d1df619949 9102:c9ed52e53526
  1302             except KeyError:
  1302             except KeyError:
  1303                 cnx = Connection(self, cnxid=cnxid)
  1303                 cnx = Connection(self, cnxid=cnxid)
  1304                 self._cnxs[cnxid] = cnx
  1304                 self._cnxs[cnxid] = cnx
  1305         return cnx
  1305         return cnx
  1306 
  1306 
       
  1307     def close_cnx(self, cnxid):
       
  1308         """Close a Connection related to a session"""
       
  1309         cnx = self._cnxs.get(cnxid, None)
       
  1310         if cnx is not None:
       
  1311             cnx.free_cnxset(ignoremode=True)
       
  1312             self._clear_thread_storage(cnx)
       
  1313             self._clear_cnx_storage(cnx)
       
  1314 
  1307     def set_cnx(self, cnxid=None):
  1315     def set_cnx(self, cnxid=None):
  1308         """set the default connection of the current thread to <cnxid>
  1316         """set the default connection of the current thread to <cnxid>
  1309 
  1317 
  1310         Connection is created if necessary"""
  1318         Connection is created if necessary"""
  1311         if cnxid is None:
  1319         if cnxid is None:
  1486         See :meth:`cubicweb.dbapi.Cursor.execute` documentation.
  1494         See :meth:`cubicweb.dbapi.Cursor.execute` documentation.
  1487         """
  1495         """
  1488         rset = self._cnx.execute(*args, **kwargs)
  1496         rset = self._cnx.execute(*args, **kwargs)
  1489         rset.req = self
  1497         rset.req = self
  1490         return rset
  1498         return rset
  1491 
       
  1492     def close_cnx(self, cnxid):
       
  1493         cnx = self._cnxs.get(cnxid, None)
       
  1494         if cnx is not None:
       
  1495             cnx.free_cnxset(ignoremode=True)
       
  1496             self._clear_thread_storage(cnx)
       
  1497             self._clear_cnx_storage(cnx)
       
  1498 
       
  1499 
  1499 
  1500     def _clear_thread_data(self, free_cnxset=True):
  1500     def _clear_thread_data(self, free_cnxset=True):
  1501         """remove everything from the thread local storage, except connections set
  1501         """remove everything from the thread local storage, except connections set
  1502         which is explicitly removed by free_cnxset, and mode which is set anyway
  1502         which is explicitly removed by free_cnxset, and mode which is set anyway
  1503         by _touch
  1503         by _touch