[dbapi] 'before-registry-reset' not called for db-api connections, cache may not be initialized
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 25 Oct 2010 10:19:03 +0200
changeset 6615 9807fb5d5f8d
parent 6614 4b9a785df0f7
child 6616 26587186b856
[dbapi] 'before-registry-reset' not called for db-api connections, cache may not be initialized
selectors.py
--- a/selectors.py	Mon Oct 25 10:18:10 2010 +0200
+++ b/selectors.py	Mon Oct 25 10:19:03 2010 +0200
@@ -777,7 +777,11 @@
 
     def score_class(self, eclass, req):
         # cache on vreg to avoid reloading issues
-        cache = req.vreg._is_instance_selector_cache
+        try:
+            cache = req.vreg._is_instance_selector_cache
+        except AttributeError:
+            # XXX 'before-registry-reset' not called for db-api connections
+            cache = req.vreg._is_instance_selector_cache = {}
         try:
             expected_eclasses = cache[self]
         except KeyError: