server/hook.py
branchstable
changeset 5067 adc2122eed03
parent 5060 ee3b856e1406
child 5072 072ae171aeb0
equal deleted inserted replaced
5066:bf5cbc351e99 5067:adc2122eed03
   546 class RQLPrecommitOperation(Operation):
   546 class RQLPrecommitOperation(Operation):
   547     def precommit_event(self):
   547     def precommit_event(self):
   548         execute = self.session.execute
   548         execute = self.session.execute
   549         for rql in self.rqls:
   549         for rql in self.rqls:
   550             execute(*rql)
   550             execute(*rql)
       
   551 
       
   552 
       
   553 class CleanupNewEidsCacheOp(SingleLastOperation):
       
   554     """on rollback of a insert query we have to remove from repository's
       
   555     type/source cache eids of entities added in that transaction.
       
   556 
       
   557     NOTE: querier's rqlst/solutions cache may have been polluted too with
       
   558     queries such as Any X WHERE X eid 32 if 32 has been rollbacked however
       
   559     generated queries are unpredictable and analysing all the cache probably
       
   560     too expensive. Notice that there is no pb when using args to specify eids
       
   561     instead of giving them into the rql string.
       
   562     """
       
   563 
       
   564     def rollback_event(self):
       
   565         """the observed connections pool has been rollbacked,
       
   566         remove inserted eid from repository type/source cache
       
   567         """
       
   568         try:
       
   569             self.session.repo.clear_caches(
       
   570                 self.session.transaction_data['neweids'])
       
   571         except KeyError:
       
   572             pass
       
   573 
       
   574 class CleanupDeletedEidsCacheOp(SingleLastOperation):
       
   575     """on commit of delete query, we have to remove from repository's
       
   576     type/source cache eids of entities deleted in that transaction.
       
   577     """
       
   578 
       
   579     def commit_event(self):
       
   580         """the observed connections pool has been rollbacked,
       
   581         remove inserted eid from repository type/source cache
       
   582         """
       
   583         try:
       
   584             self.session.repo.clear_caches(
       
   585                 self.session.transaction_data['pendingeids'])
       
   586         except KeyError:
       
   587             pass