[Checkins] SVN: Products.ZCatalog/trunk/src/Products/ZCatalog/plan.py Split catalog plan loading code into two methods

Hanno Schlichting hannosch at hannosch.eu
Thu Nov 17 10:50:59 UTC 2011


Log message for revision 123405:
  Split catalog plan loading code into two methods
  

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

-=-
Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/plan.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/plan.py	2011-11-17 08:30:15 UTC (rev 123404)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/plan.py	2011-11-17 10:50:58 UTC (rev 123405)
@@ -97,26 +97,30 @@
         if location:
             try:
                 pmap = resolve(location)
-                logger.info('loaded priority %d map(s) from %s',
-                    len(pmap), location)
-                # Convert the simple benchmark tuples to namedtuples
-                new_plan = {}
-                for cid, plan in pmap.items():
-                    new_plan[cid] = {}
-                    for querykey, details in plan.items():
-                        new_plan[cid][querykey] = {}
-                        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
+                cls.load_from_path(location, pmap)
             except ImportError:
                 logger.warning('could not load priority map from %s', location)
 
+    @classmethod
+    def load_from_path(cls, location, pmap):
+        logger.info('loaded priority %d map(s) from %s',
+            len(pmap), location)
+        # Convert the simple benchmark tuples to namedtuples
+        new_plan = {}
+        for cid, plan in pmap.items():
+            new_plan[cid] = {}
+            for querykey, details in plan.items():
+                new_plan[cid][querykey] = {}
+                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
 
+
 class Reports(NestedDict):
     """This holds a structure of nested dicts.
 



More information about the checkins mailing list