# HG changeset patch # User Pierre-Yves David # Date 1364224414 -3600 # Node ID 8f2786492369b4c31af0b23788ca33f51d01d627 # Parent 07f453bf72e804f311186020b0a2effc72e2a696 [session/transaction] move entity life utility on transaction This access transaction related data and therefor should live in transaction. diff -r 07f453bf72e8 -r 8f2786492369 server/session.py --- a/server/session.py Mon Mar 25 16:20:25 2013 +0100 +++ b/server/session.py Mon Mar 25 16:13:34 2013 +0100 @@ -274,6 +274,23 @@ else: del self.data['ecache'][eid] + # Tracking of entity added of removed in the transaction ################## + # + # Those are function to allows cheap call from client in other process. + + def deleted_in_transaction(self, eid): + """return True if the entity of the given eid is being deleted in the + current transaction + """ + return eid in self.data.get('pendingeids', ()) + + def added_in_transaction(self, eid): + """return True if the entity of the given eid is being created in the + current transaction + """ + return eid in self.data.get('neweids', ()) + + def tx_attr(attr_name): @@ -652,17 +669,8 @@ self.cnxset.reconnect(source) return source.doexec(self, sql, args, rollback=rollback_on_failure) - def deleted_in_transaction(self, eid): - """return True if the entity of the given eid is being deleted in the - current transaction - """ - return eid in self._tx.data.get('pendingeids', ()) - - def added_in_transaction(self, eid): - """return True if the entity of the given eid is being created in the - current transaction - """ - return eid in self._tx.data.get('neweids', ()) + deleted_in_transaction = tx_meth('deleted_in_transaction') + added_in_transaction = tx_meth('added_in_transaction') def rtype_eids_rdef(self, rtype, eidfrom, eidto): # use type_and_source_from_eid instead of type_from_eid for optimization