[transaction] small simplification in ecache code
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Mon, 25 Mar 2013 16:20:25 +0100
changeset 8784 07f453bf72e8
parent 8783 c024365ac8ac
child 8785 8f2786492369
[transaction] small simplification in ecache code A single assignation is simpler.
server/session.py
--- a/server/session.py	Mon Mar 25 14:16:16 2013 +0100
+++ b/server/session.py	Mon Mar 25 16:20:25 2013 +0100
@@ -254,11 +254,8 @@
 
     def set_entity_cache(self, entity):
         """Add `entity` to the transaction entity cache"""
-        try:
-            self.data['ecache'].setdefault(entity.eid, entity)
-        except KeyError:
-            self.data['ecache'] = ecache = {}
-            ecache[entity.eid] = entity
+        ecache = self.data.setdefault('ecache', {})
+        ecache.setdefault(entity.eid, entity)
 
     def entity_cache(self, eid):
         """get cache entity for `eid`"""