1309 """Close a Connection related to a session""" |
1309 """Close a Connection related to a session""" |
1310 cnx = self._cnxs.get(cnxid, None) |
1310 cnx = self._cnxs.get(cnxid, None) |
1311 if cnx is not None: |
1311 if cnx is not None: |
1312 cnx.free_cnxset(ignoremode=True) |
1312 cnx.free_cnxset(ignoremode=True) |
1313 self._clear_thread_storage(cnx) |
1313 self._clear_thread_storage(cnx) |
1314 self._clear_cnx_storage(cnx) |
1314 cnx.clear() |
1315 |
1315 |
1316 def set_cnx(self, cnxid=None): |
1316 def set_cnx(self, cnxid=None): |
1317 """set the default connection of the current thread to <cnxid> |
1317 """set the default connection of the current thread to <cnxid> |
1318 |
1318 |
1319 Connection is created if necessary""" |
1319 Connection is created if necessary""" |
1511 if free_cnxset: |
1511 if free_cnxset: |
1512 self.free_cnxset() |
1512 self.free_cnxset() |
1513 if cnx.ctx_count == 0: |
1513 if cnx.ctx_count == 0: |
1514 self._clear_thread_storage(cnx) |
1514 self._clear_thread_storage(cnx) |
1515 else: |
1515 else: |
1516 self._clear_cnx_storage(cnx) |
1516 cnx.clear() |
1517 else: |
1517 else: |
1518 self._clear_cnx_storage(cnx) |
1518 cnx.clear() |
1519 |
1519 |
1520 def _clear_thread_storage(self, cnx): |
1520 def _clear_thread_storage(self, cnx): |
1521 self._cnxs.pop(cnx.connectionid, None) |
1521 self._cnxs.pop(cnx.connectionid, None) |
1522 try: |
1522 try: |
1523 if self.__threaddata.cnx is cnx: |
1523 if self.__threaddata.cnx is cnx: |
1524 del self.__threaddata.cnx |
1524 del self.__threaddata.cnx |
1525 except AttributeError: |
1525 except AttributeError: |
1526 pass |
1526 pass |
1527 |
1527 |
1528 def _clear_cnx_storage(self, cnx): |
|
1529 cnx.clear() |
|
1530 |
1528 |
1531 def commit(self, free_cnxset=True, reset_pool=None): |
1529 def commit(self, free_cnxset=True, reset_pool=None): |
1532 """commit the current session's transaction""" |
1530 """commit the current session's transaction""" |
1533 cstate = self._cnx.commit_state |
1531 cstate = self._cnx.commit_state |
1534 if cstate == 'uncommitable': |
1532 if cstate == 'uncommitable': |