[Zope-Checkins] SVN: Zope/branches/andig-catalog-report/src/Products/ZCatalog/CatalogReport.py I don't like lambda's to return static results

Hanno Schlichting hannosch at hannosch.eu
Sat Jul 24 13:16:22 EDT 2010


Log message for revision 115036:
  I don't like lambda's to return static results
  

Changed:
  U   Zope/branches/andig-catalog-report/src/Products/ZCatalog/CatalogReport.py

-=-
Modified: Zope/branches/andig-catalog-report/src/Products/ZCatalog/CatalogReport.py
===================================================================
--- Zope/branches/andig-catalog-report/src/Products/ZCatalog/CatalogReport.py	2010-07-24 16:37:58 UTC (rev 115035)
+++ Zope/branches/andig-catalog-report/src/Products/ZCatalog/CatalogReport.py	2010-07-24 17:16:22 UTC (rev 115036)
@@ -14,6 +14,8 @@
 import time
 from thread import allocate_lock
 
+from Acquisition import aq_base
+from Acquisition import aq_parent
 from Products.PluginIndexes.interfaces import IUniqueValueIndex
 
 reportlock = allocate_lock()
@@ -120,11 +122,12 @@
         self.request = request
         self.threshold = threshold
 
-        # TODO: how to get an unique id?
-        getPhysicalPath = getattr(catalog.aq_parent,
-                                  'getPhysicalPath',
-                                  lambda: ['', 'DummyCatalog'])
-        self.cid = tuple(getPhysicalPath())
+        path = getattr(aq_parent(catalog), 'getPhysicalPath', None)
+        if path is None:
+            path = ('', 'NonPersistentCatalog')
+        else:
+            path = tuple(path())
+        self.cid = path
 
     def stop(self):
         super(CatalogReport, self).stop()



More information about the Zope-Checkins mailing list