[zopeorg-checkins] CVS: Products/ZopeOrg-NV - __init__.py:1.26

Brian Lloyd brian at zope.com
Wed Aug 6 10:08:31 EDT 2003


Update of /cvs-zopeorg/Products/ZopeOrg-NV
In directory cvs.zope.org:/tmp/cvs-serv11958

Modified Files:
	__init__.py 
Log Message:
checkin hack to avoid calling catalog TTW


=== Products/ZopeOrg-NV/__init__.py 1.25 => 1.26 ===
 class ImplicitAcquirerWrapper:
     pass
 
+
+from Products.CMFCore.CatalogTool import CatalogTool
+
+# Monkey-patch the catalog tool to avoid unbounded searches!
+_searchResults = CatalogTool.searchResults
+
+def searchResults(self, REQUEST=None, **kw):
+    ''
+    if (len(kw) == 0) and (REQUEST is not None):
+        url = REQUEST['URL']
+        if url.endswith('portal_catalog') or \
+           url.endswith('portal_catalog/') or \
+           url.endswith('portal_catalog/index_html'):
+            raise ValueError, 'catalog not callable from the web'
+
+    return apply(_searchResults, (self, REQUEST), kw)
+    
+CatalogTool.__call__ = searchResults
+
+
 from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
 DefaultDublinCoreImpl._DefaultDublinCoreImpl__FLOOR_DATE   = DateTime(1979, 0)
 DefaultDublinCoreImpl._DefaultDublinCoreImpl__CEILING_DATE = DateTime(2979, 0)





More information about the zopeorg-checkins mailing list