[CMF-checkins] SVN: CMF/branches/yuppie-setup_cleanup/CMF - removed enumerateIndexes, enumerateLexicons, enumerateColumns and _initIndexes from CatalogTool

Yvo Schubbe y.2005- at wcm-solutions.de
Thu Oct 20 09:14:06 EDT 2005


Log message for revision 39528:
  - removed enumerateIndexes, enumerateLexicons, enumerateColumns and _initIndexes from CatalogTool
  - fixed unit tests

Changed:
  U   CMF/branches/yuppie-setup_cleanup/CMFCore/CatalogTool.py
  U   CMF/branches/yuppie-setup_cleanup/CMFCore/tests/test_CatalogTool.py
  U   CMF/branches/yuppie-setup_cleanup/CMFCore/tests/test_PortalFolder.py
  U   CMF/branches/yuppie-setup_cleanup/CMFTopic/tests/test_DateC.py
  U   CMF/branches/yuppie-setup_cleanup/CMFUid/tests/test_uidhandling.py

-=-
Modified: CMF/branches/yuppie-setup_cleanup/CMFCore/CatalogTool.py
===================================================================
--- CMF/branches/yuppie-setup_cleanup/CMFCore/CatalogTool.py	2005-10-20 12:34:10 UTC (rev 39527)
+++ CMF/branches/yuppie-setup_cleanup/CMFCore/CatalogTool.py	2005-10-20 13:14:06 UTC (rev 39528)
@@ -21,11 +21,6 @@
 from Globals import DTMLFile
 from Globals import InitializeClass
 from Products.ZCatalog.ZCatalog import ZCatalog
-from Products.ZCTextIndex.HTMLSplitter import HTMLWordSplitter
-from Products.ZCTextIndex.Lexicon import CaseNormalizer
-from Products.ZCTextIndex.Lexicon import Splitter
-from Products.ZCTextIndex.Lexicon import StopWordRemover
-from Products.ZCTextIndex.ZCTextIndex import PLexicon
 from zope.interface import implements
 
 from ActionProviderBase import ActionProviderBase
@@ -42,7 +37,6 @@
 from utils import _getAuthenticatedUser
 from utils import _mergedLocalRoles
 from utils import getToolByName
-from utils import SimpleRecord
 from utils import UniqueObject
 
 
@@ -102,97 +96,8 @@
 
     def __init__(self):
         ZCatalog.__init__(self, self.getId())
-        self._initIndexes()
 
     #
-    #   Subclass extension interface
-    #
-    security.declarePublic('enumerateIndexes') # Subclass can call
-    def enumerateIndexes(self):
-        #   Return a list of ( index_name, type, extra ) tuples for the initial
-        #   index set.
-        plaintext_extra = SimpleRecord( lexicon_id='plaintext_lexicon'
-                                      , index_type='Okapi BM25 Rank'
-                                      )
-        htmltext_extra = SimpleRecord( lexicon_id='htmltext_lexicon'
-                                     , index_type='Okapi BM25 Rank'
-                                     )
-
-        return ( ('Title', 'ZCTextIndex', plaintext_extra)
-               , ('Subject', 'KeywordIndex', None)
-               , ('Description', 'ZCTextIndex', plaintext_extra)
-               , ('listCreators', 'KeywordIndex', None)
-               , ('SearchableText', 'ZCTextIndex', htmltext_extra)
-               , ('Date', 'DateIndex', None)
-               , ('Type', 'FieldIndex', None)
-               , ('created', 'DateIndex', None)
-               , ('effective', 'DateIndex', None)
-               , ('expires', 'DateIndex', None)
-               , ('modified', 'DateIndex', None)
-               , ('allowedRolesAndUsers', 'KeywordIndex', None)
-               , ('review_state', 'FieldIndex', None)
-               , ('in_reply_to', 'FieldIndex', None)
-               , ('getId', 'FieldIndex', None)
-               , ('path', 'PathIndex', None)
-               , ('portal_type', 'FieldIndex', None)
-               )
-
-    security.declarePublic('enumerateLexicons')
-    def enumerateLexicons(self):
-        return (
-                 ( 'plaintext_lexicon'
-                 , Splitter()
-                 , CaseNormalizer()
-                 , StopWordRemover()
-                 )
-               , ( 'htmltext_lexicon'
-                 , HTMLWordSplitter()
-                 , CaseNormalizer()
-                 , StopWordRemover()
-                 )
-               )
-
-    security.declarePublic('enumerateColumns')
-    def enumerateColumns(self):
-        #   Return a sequence of schema names to be cached.
-        return ( 'Subject'
-               , 'Title'
-               , 'Description'
-               , 'Type'
-               , 'review_state'
-               , 'listCreators'
-               , 'Date'
-               , 'getIcon'
-               , 'created'
-               , 'effective'
-               , 'expires'
-               , 'modified'
-               , 'CreationDate'
-               , 'EffectiveDate'
-               , 'ExpirationDate'
-               , 'ModificationDate'
-               , 'getId'
-               , 'portal_type'
-               )
-
-    def _initIndexes(self):
-        # ZCTextIndex lexicons
-        for id, splitter, normalizer, sw_remover in self.enumerateLexicons():
-            lexicon = PLexicon(id, '', splitter, normalizer, sw_remover)
-            self._setObject(id, lexicon)
-
-        # Content indexes
-        self._catalog.indexes.clear()
-        for index_name, index_type, extra in self.enumerateIndexes():
-            self.addIndex(index_name, index_type, extra=extra)
-
-        # Cached metadata
-        self._catalog.names = ()
-        self._catalog.schema.clear()
-        for column_name in self.enumerateColumns():
-            self.addColumn(column_name)
-
-    #
     #   ZMI methods
     #
     security.declareProtected(ManagePortal, 'manage_overview')

Modified: CMF/branches/yuppie-setup_cleanup/CMFCore/tests/test_CatalogTool.py
===================================================================
--- CMF/branches/yuppie-setup_cleanup/CMFCore/tests/test_CatalogTool.py	2005-10-20 12:34:10 UTC (rev 39527)
+++ CMF/branches/yuppie-setup_cleanup/CMFCore/tests/test_CatalogTool.py	2005-10-20 13:14:06 UTC (rev 39528)
@@ -91,6 +91,7 @@
             argument, 'idxs', to 'catalog_object'.
         """
         tool = self._makeOne()
+        tool.addIndex('SearchableText', 'KeywordIndex')
         dummy = DummyContent(catalog=1)
 
         tool.catalog_object( dummy, '/dummy' )
@@ -98,6 +99,7 @@
 
     def test_search_anonymous(self):
         catalog = self._makeOne()
+        catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
         dummy = DummyContent(catalog=1)
         catalog.catalog_object(dummy, '/dummy')
 
@@ -106,6 +108,9 @@
 
     def test_search_inactive(self):
         catalog = self._makeOne()
+        catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
+        catalog.addIndex('effective', 'DateIndex')
+        catalog.addIndex('expires', 'DateIndex')
         now = DateTime()
         dummy = DummyContent(catalog=1)
         dummy._View_Permission = ('Blob',)
@@ -128,6 +133,9 @@
 
     def test_search_restrict_manager(self):
         catalog = self._makeOne()
+        catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
+        catalog.addIndex('effective', 'DateIndex')
+        catalog.addIndex('expires', 'DateIndex')
         now = DateTime()
         dummy = DummyContent(catalog=1)
 
@@ -159,6 +167,9 @@
 
     def test_search_restrict_inactive(self):
         catalog = self._makeOne()
+        catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
+        catalog.addIndex('effective', 'DateIndex')
+        catalog.addIndex('expires', 'DateIndex')
         now = DateTime()
         dummy = DummyContent(catalog=1)
         dummy._View_Permission = ('Blob',)
@@ -189,6 +200,9 @@
 
     def test_search_restrict_visible(self):
         catalog = self._makeOne()
+        catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
+        catalog.addIndex('effective', 'DateIndex')
+        catalog.addIndex('expires', 'DateIndex')
         now = DateTime()
         dummy = DummyContent(catalog=1)
         dummy._View_Permission = ('Blob',)

Modified: CMF/branches/yuppie-setup_cleanup/CMFCore/tests/test_PortalFolder.py
===================================================================
--- CMF/branches/yuppie-setup_cleanup/CMFCore/tests/test_PortalFolder.py	2005-10-20 12:34:10 UTC (rev 39527)
+++ CMF/branches/yuppie-setup_cleanup/CMFCore/tests/test_PortalFolder.py	2005-10-20 13:14:06 UTC (rev 39528)
@@ -444,6 +444,7 @@
 
         ttool = self.site._setObject( 'portal_types', TypesTool() )
         ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+        ctool.addIndex('getId', 'FieldIndex')
         self.assertEqual( len(ctool), 0 )
 
         folder = self._makeOne('folder')

Modified: CMF/branches/yuppie-setup_cleanup/CMFTopic/tests/test_DateC.py
===================================================================
--- CMF/branches/yuppie-setup_cleanup/CMFTopic/tests/test_DateC.py	2005-10-20 12:34:10 UTC (rev 39527)
+++ CMF/branches/yuppie-setup_cleanup/CMFTopic/tests/test_DateC.py	2005-10-20 13:14:06 UTC (rev 39528)
@@ -20,7 +20,10 @@
 import Zope2
 Zope2.startup()
 
+import Products
 from DateTime.DateTime import DateTime
+from Products.Five import zcml
+from zope.app.tests.placelesssetup import PlacelessSetup
 
 from Products.CMFCore.tests.base.testcase import RequestTest
 from Products.CMFCore.tests.base.dummy import DummyContent
@@ -149,7 +152,7 @@
         self.assertEqual( expect_now.Date(), DateTime().Date() )
         self.assertEqual( result[0][1]['range'], 'min:max' )
 
-class FriendlyDateCriterionFunctionalTests(RequestTest):
+class FriendlyDateCriterionFunctionalTests(PlacelessSetup, RequestTest):
     # Test the date criterion using a "real CMF" with catalog etc.
     selectable_diffs = [0, 1, 2, 5, 7, 14, 31, 93, 186, 365, 730]
     nonzero_diffs = [1, 2, 5, 7, 14, 31, 93, 186, 365, 730]
@@ -157,7 +160,12 @@
     day_diffs.extend(selectable_diffs)
 
     def setUp(self):
+        PlacelessSetup.setUp(self)
         RequestTest.setUp(self)
+        zcml.load_config('meta.zcml', Products.Five)
+        zcml.load_config('configure.zcml', Products.GenericSetup)
+        zcml.load_config('configure.zcml', Products.CMFCore)
+
         factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite
         factory('site', 'CMFDefault:default', snapshot=False)
         self.site = self.root.site
@@ -179,6 +187,9 @@
             dummy_ob.modified_date = self.now + i
             dummy_ob.reindexObject()
 
+    def tearDown(self):
+        RequestTest.tearDown(self)
+        PlacelessSetup.tearDown(self)
 
     def test_Harness(self):
         # Make sure the test harness is set up OK

Modified: CMF/branches/yuppie-setup_cleanup/CMFUid/tests/test_uidhandling.py
===================================================================
--- CMF/branches/yuppie-setup_cleanup/CMFUid/tests/test_uidhandling.py	2005-10-20 12:34:10 UTC (rev 39527)
+++ CMF/branches/yuppie-setup_cleanup/CMFUid/tests/test_uidhandling.py	2005-10-20 13:14:06 UTC (rev 39528)
@@ -24,13 +24,6 @@
 from Products.CMFCore.tests.base.testcase import SecurityTest
 
 
-def removeUnnecessaryIndexes(catalog):
-    indexes = [id[0] for id in catalog.enumerateIndexes()]
-    columns = catalog.enumerateColumns()
-    catalog.manage_delIndex(indexes)
-    catalog.manage_delColumn(columns)
-
-
 class DummyUid:
     """A dummy uid that surely is of different type of the generated ones.
     """
@@ -58,8 +51,6 @@
         self.root._setObject('dummy', DummyContent(id='dummy'))
         self.root._setObject('dummy2', DummyContent(id='dummy2'))
 
-        removeUnnecessaryIndexes(self.root.portal_catalog)
-
     def test_z3interfaces(self):
         from zope.interface.verify import verifyClass
         from Products.CMFUid.interfaces import IUniqueIdBrainQuery



More information about the CMF-checkins mailing list