fix clear_all_cache: ensure we don't remove eid from entity's dict stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 14 Oct 2009 12:49:20 +0200
branchstable
changeset 3665 42f3a66cab51
parent 3664 af7ca3597b8d
child 3666 7d0f6234b001
fix clear_all_cache: ensure we don't remove eid from entity's dict
entity.py
--- a/entity.py	Wed Oct 14 12:48:51 2009 +0200
+++ b/entity.py	Wed Oct 14 12:49:20 2009 +0200
@@ -845,9 +845,14 @@
             self._related_cache.pop('%s_%s' % (rtype, role), None)
 
     def clear_all_caches(self):
+        haseid = 'eid' in self
         self.clear()
         for rschema, _, role in self.e_schema.relation_definitions():
             self.clear_related_cache(rschema.type, role)
+        # set eid if it was in, else we may get nasty error while editing this
+        # entity if it's bound to a repo session
+        if haseid:
+            self['eid'] = self.eid
 
     # raw edition utilities ###################################################