server/repository.py
changeset 9622 637a12b0d3a2
parent 9609 e7d38148799e
child 9623 2171da5b9234
equal deleted inserted replaced
9621:202c4797e365 9622:637a12b0d3a2
   700             self._pyro_sessions[threading.currentThread()] = session
   700             self._pyro_sessions[threading.currentThread()] = session
   701         user._cw = user.cw_rset.req = session
   701         user._cw = user.cw_rset.req = session
   702         user.cw_clear_relation_cache()
   702         user.cw_clear_relation_cache()
   703         self._sessions[session.sessionid] = session
   703         self._sessions[session.sessionid] = session
   704         self.info('opened session %s for user %s', session.sessionid, login)
   704         self.info('opened session %s for user %s', session.sessionid, login)
   705         self.hm.call_hooks('session_open', session)
   705         with session.new_cnx() as cnx:
   706         # commit session at this point in case write operation has been done
   706             self.hm.call_hooks('session_open', cnx)
   707         # during `session_open` hooks
   707             # commit connection at this point in case write operation has been
   708         session.commit()
   708             # done during `session_open` hooks
       
   709             cnx.commit()
   709         return session.sessionid
   710         return session.sessionid
   710 
   711 
   711     def execute(self, sessionid, rqlstring, args=None, build_descr=True,
   712     def execute(self, sessionid, rqlstring, args=None, build_descr=True,
   712                 txid=None):
   713                 txid=None):
   713         """execute a RQL query
   714         """execute a RQL query
   823     def close(self, sessionid, txid=None, checkshuttingdown=True):
   824     def close(self, sessionid, txid=None, checkshuttingdown=True):
   824         """close the session with the given id"""
   825         """close the session with the given id"""
   825         session = self._get_session(sessionid, setcnxset=True, txid=txid,
   826         session = self._get_session(sessionid, setcnxset=True, txid=txid,
   826                                     checkshuttingdown=checkshuttingdown)
   827                                     checkshuttingdown=checkshuttingdown)
   827         # operation uncommited before close are rolled back before hook is called
   828         # operation uncommited before close are rolled back before hook is called
   828         session.rollback(free_cnxset=False)
   829         session._cnx.rollback(free_cnxset=False)
   829         self.hm.call_hooks('session_close', session)
   830         with session.new_cnx() as cnx:
   830         # commit session at this point in case write operation has been done
   831             self.hm.call_hooks('session_close', cnx)
   831         # during `session_close` hooks
   832             # commit connection at this point in case write operation has been
   832         session.commit()
   833             # done during `session_close` hooks
       
   834             cnx.commit()
   833         session.close()
   835         session.close()
   834         if threading.currentThread() in self._pyro_sessions:
   836         if threading.currentThread() in self._pyro_sessions:
   835             self._pyro_sessions[threading.currentThread()] = None
   837             self._pyro_sessions[threading.currentThread()] = None
   836         del self._sessions[sessionid]
   838         del self._sessions[sessionid]
   837         self.info('closed session %s for user %s', sessionid, session.user.login)
   839         self.info('closed session %s for user %s', sessionid, session.user.login)