From a40cbe4d5e96b8851e82ed356453640c004d834a Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 9 Jul 2013 17:35:15 +0200
Subject: [PATCH] ZSQLCatalog: Use a transactional cache instead of a global
 cache.

Not perfect yet (what if definitions change during the same transaction ?),
but better than previous state.
---
 product/ZSQLCatalog/SQLCatalog.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/product/ZSQLCatalog/SQLCatalog.py b/product/ZSQLCatalog/SQLCatalog.py
index b202dd7496..6245f4c967 100644
--- a/product/ZSQLCatalog/SQLCatalog.py
+++ b/product/ZSQLCatalog/SQLCatalog.py
@@ -289,7 +289,6 @@ class LazyIndexationParameterList(tuple):
 
 ContainerAssertions[LazyIndexationParameterList] = 1
 
-related_key_definition_cache = {}
 related_key_warned_column_set = set()
 
 class Catalog(Folder,
@@ -2031,6 +2030,8 @@ class Catalog(Folder,
       Returns the definition of given related key name if found, None
       otherwise.
     """
+    related_key_definition_cache = getTransactionalVariable().setdefault(
+      'SQLCatalog.getRelatedKeyDefinition', {})
     try:
       result = related_key_definition_cache[key]
     except KeyError:
-- 
2.30.9