[Checkins] SVN: Products.ZCatalog/trunk/src/Products/ZCatalog/ Load back a value index spec from a stored priority map

Hanno Schlichting hannosch at hannosch.eu
Thu Oct 20 09:39:53 EST 2011


Log message for revision 123123:
  Load back a value index spec from a stored priority map
  

Changed:
  U   Products.ZCatalog/trunk/src/Products/ZCatalog/plan.py
  U   Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_plan.py

-=-
Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/plan.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/plan.py	2011-10-20 14:34:13 UTC (rev 123122)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/plan.py	2011-10-20 14:39:53 UTC (rev 123123)
@@ -105,9 +105,12 @@
                     new_plan[cid] = {}
                     for querykey, details in plan.items():
                         new_plan[cid][querykey] = {}
-                        for indexname, benchmark in details.items():
-                            new_plan[cid][querykey][indexname] = \
-                                Benchmark(*benchmark)
+                        if isinstance(details, (frozenset, set)):
+                            new_plan[cid][querykey] = details
+                        else:
+                            for indexname, benchmark in details.items():
+                                new_plan[cid][querykey][indexname] = \
+                                    Benchmark(*benchmark)
                 with cls.lock:
                     cls.value = new_plan
             except ImportError:

Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_plan.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_plan.py	2011-10-20 14:34:13 UTC (rev 123122)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_plan.py	2011-10-20 14:39:53 UTC (rev 123123)
@@ -32,10 +32,11 @@
 
 TESTMAP = {
     '/folder/catalog': {
+        'VALUE_INDEXES': frozenset(['index1']),
         'index1 index2': {
             'index1': (2.0, 3, True),
             'index2': (1.5, 2, False),
-        }
+        },
     }
 }
 
@@ -127,9 +128,11 @@
             os.environ['ZCATALOGQUERYPLAN'] = \
                 'Products.ZCatalog.tests.test_plan.TESTMAP'
             self.pmap.load_default()
-            expected = {'/folder/catalog': {'index1 index2': {
-                'index1': Benchmark(duration=2.0, hits=3, limit=True),
-                'index2': Benchmark(duration=1.5, hits=2, limit=False),
+            expected = {'/folder/catalog': {
+                'VALUE_INDEXES': frozenset(['index1']),
+                'index1 index2': {
+                    'index1': Benchmark(duration=2.0, hits=3, limit=True),
+                    'index2': Benchmark(duration=1.5, hits=2, limit=False),
             }}}
             self.assertEquals(self.pmap.get_value(), expected)
         finally:



More information about the checkins mailing list