server/session.py
changeset 8785 8f2786492369
parent 8784 07f453bf72e8
child 8786 c2bc0b804982
equal deleted inserted replaced
8784:07f453bf72e8 8785:8f2786492369
   271         If eid is None, the whole cache is dropped"""
   271         If eid is None, the whole cache is dropped"""
   272         if eid is None:
   272         if eid is None:
   273             self.data.pop('ecache', None)
   273             self.data.pop('ecache', None)
   274         else:
   274         else:
   275             del self.data['ecache'][eid]
   275             del self.data['ecache'][eid]
       
   276 
       
   277     # Tracking of entity added of removed in the transaction ##################
       
   278     #
       
   279     # Those are function to  allows cheap call from client in other process.
       
   280 
       
   281     def deleted_in_transaction(self, eid):
       
   282         """return True if the entity of the given eid is being deleted in the
       
   283         current transaction
       
   284         """
       
   285         return eid in self.data.get('pendingeids', ())
       
   286 
       
   287     def added_in_transaction(self, eid):
       
   288         """return True if the entity of the given eid is being created in the
       
   289         current transaction
       
   290         """
       
   291         return eid in self.data.get('neweids', ())
       
   292 
   276 
   293 
   277 
   294 
   278 
   295 
   279 def tx_attr(attr_name):
   296 def tx_attr(attr_name):
   280     """return a property to forward attribute access to transaction.
   297     """return a property to forward attribute access to transaction.
   650                 raise
   667                 raise
   651             source.warning("trying to reconnect")
   668             source.warning("trying to reconnect")
   652             self.cnxset.reconnect(source)
   669             self.cnxset.reconnect(source)
   653             return source.doexec(self, sql, args, rollback=rollback_on_failure)
   670             return source.doexec(self, sql, args, rollback=rollback_on_failure)
   654 
   671 
   655     def deleted_in_transaction(self, eid):
   672     deleted_in_transaction =  tx_meth('deleted_in_transaction')
   656         """return True if the entity of the given eid is being deleted in the
   673     added_in_transaction   =  tx_meth('added_in_transaction')
   657         current transaction
       
   658         """
       
   659         return eid in self._tx.data.get('pendingeids', ())
       
   660 
       
   661     def added_in_transaction(self, eid):
       
   662         """return True if the entity of the given eid is being created in the
       
   663         current transaction
       
   664         """
       
   665         return eid in self._tx.data.get('neweids', ())
       
   666 
   674 
   667     def rtype_eids_rdef(self, rtype, eidfrom, eidto):
   675     def rtype_eids_rdef(self, rtype, eidfrom, eidto):
   668         # use type_and_source_from_eid instead of type_from_eid for optimization
   676         # use type_and_source_from_eid instead of type_from_eid for optimization
   669         # (avoid two extra methods call)
   677         # (avoid two extra methods call)
   670         subjtype = self.repo.type_and_source_from_eid(eidfrom, self)[0]
   678         subjtype = self.repo.type_and_source_from_eid(eidfrom, self)[0]