entity.py
changeset 10830 d41f13a919ff
parent 10689 49a62b8f6d43
child 10833 f585add0fed9
--- a/entity.py	Mon Oct 19 23:23:46 2015 +0000
+++ b/entity.py	Mon Oct 12 09:53:51 2015 +0200
@@ -147,6 +147,7 @@
         pruned[(lt_rtype, lt_role)] = eids
     return pruned
 
+
 class Entity(AppObject):
     """an entity instance has e_schema automagically set on
     the class and instances has access to their issuing cursor.
@@ -533,6 +534,7 @@
     def __init__(self, req, rset=None, row=None, col=0):
         AppObject.__init__(self, req, rset=rset, row=row, col=col)
         self._cw_related_cache = {}
+        self._cw_adapters_cache = {}
         if rset is not None:
             self.eid = rset[row][col]
         else:
@@ -570,10 +572,7 @@
 
         return None if it can not be adapted.
         """
-        try:
-            cache = self._cw_adapters_cache
-        except AttributeError:
-            self._cw_adapters_cache = cache = {}
+        cache = self._cw_adapters_cache
         try:
             return cache[interface]
         except KeyError:
@@ -1239,8 +1238,8 @@
         no relation is given
         """
         if rtype is None:
-            self._cw_related_cache = {}
-            self._cw_adapters_cache = {}
+            self._cw_related_cache.clear()
+            self._cw_adapters_cache.clear()
         else:
             assert role
             self._cw_related_cache.pop('%s_%s' % (rtype, role), None)