server/session.py
changeset 8784 07f453bf72e8
parent 8783 c024365ac8ac
child 8785 8f2786492369
equal deleted inserted replaced
8783:c024365ac8ac 8784:07f453bf72e8
   252     # an acceptable risk. Anyway we could activate it or not according to a
   252     # an acceptable risk. Anyway we could activate it or not according to a
   253     # configuration option
   253     # configuration option
   254 
   254 
   255     def set_entity_cache(self, entity):
   255     def set_entity_cache(self, entity):
   256         """Add `entity` to the transaction entity cache"""
   256         """Add `entity` to the transaction entity cache"""
   257         try:
   257         ecache = self.data.setdefault('ecache', {})
   258             self.data['ecache'].setdefault(entity.eid, entity)
   258         ecache.setdefault(entity.eid, entity)
   259         except KeyError:
       
   260             self.data['ecache'] = ecache = {}
       
   261             ecache[entity.eid] = entity
       
   262 
   259 
   263     def entity_cache(self, eid):
   260     def entity_cache(self, eid):
   264         """get cache entity for `eid`"""
   261         """get cache entity for `eid`"""
   265         return self.data['ecache'][eid]
   262         return self.data['ecache'][eid]
   266 
   263