[Zope-Checkins] CVS: Zope2 - Catalog.py:1.70.6.1 ZCatalog.py:1.88.6.1

andreas@digicool.com andreas@digicool.com
Wed, 9 May 2001 09:26:42 -0400 (EDT)


Update of /cvs-repository/Zope2/lib/python/Products/ZCatalog
In directory korak:/tmp/cvs-serv8734/lib/python/Products/ZCatalog

Modified Files:
      Tag: ajung-dropin-registry
	Catalog.py ZCatalog.py 
Log Message:




--- Updated File Catalog.py in package Zope2 --
--- Catalog.py	2001/04/27 18:07:13	1.70
+++ Catalog.py	2001/05/09 13:26:42	1.70.6.1
@@ -86,7 +86,7 @@
 from Persistence import Persistent
 import Acquisition
 import ExtensionClass
-from SearchIndex import UnIndex, UnTextIndex, UnKeywordIndex
+from SearchIndex import UnIndex, UnTextIndex, UnKeywordIndex, PathIndex
 from SearchIndex.Lexicon import Lexicon
 from MultiMapping import MultiMapping
 from string import lower
@@ -151,6 +151,14 @@
             
         self.updateBrains()
 
+    def replaceIndexes(self, indexes):
+        """Replace the existing indexes with a new index container, returning
+        the old container."""
+
+        oldindexes = self.indexes
+        self.indexes = indexes
+        return oldindexes
+
     def clear(self):
         """ clear catalog """
         
@@ -336,21 +344,28 @@
         # pluggable and managable
 
         indexes = self.indexes
-        if index_type == 'FieldIndex':
-            indexes[name] = UnIndex.UnIndex(name)
-        elif index_type == 'TextIndex':
-            lexicon=self.lexicon
-            if type(lexicon) is type(''):
-                lexicon=getattr(self, lexicon).getLexicon()
-                
-            indexes[name] = UnTextIndex.UnTextIndex(name, None, None, lexicon)
-        elif index_type == 'KeywordIndex':
-            indexes[name] = UnKeywordIndex.UnKeywordIndex(name)
+
+        if hasattr(indexes,"__supports_pluggable_indexes__"):
+            indexes.addIndex(self, name, index_type)
         else:
-            raise 'Unknown Index Type', (
-                "%s invalid - must be one of %s"
-                % (index_type, ['FieldIndex', 'TextIndex', 'KeywordIndex'])
-                )
+            if index_type == 'FieldIndex':
+                indexes[name] = UnIndex.UnIndex(name)
+            elif index_type == 'TextIndex':
+                lexicon=self.lexicon
+                if type(lexicon) is type(''):
+                    lexicon=getattr(self, lexicon).getLexicon()
+                
+                indexes[name] = UnTextIndex.UnTextIndex(name, None, None,
+                    lexicon)
+            elif index_type == 'KeywordIndex':
+                indexes[name] = UnKeywordIndex.UnKeywordIndex(name)
+            elif index_type == 'PathIndex':
+                indexes[name] = PathIndex.PathIndex(name)
+            else:
+                raise 'Unknown Index Type', (
+                    "%s invalid - must be one of %s"
+                    % (index_type, ['FieldIndex', 'TextIndex', 'KeywordIndex','PathIndex'])
+                    )
 
         self.indexes = indexes
 

--- Updated File ZCatalog.py in package Zope2 --
--- ZCatalog.py	2001/04/27 20:27:49	1.88
+++ ZCatalog.py	2001/05/09 13:26:42	1.88.6.1
@@ -100,6 +100,7 @@
 from Vocabulary import Vocabulary
 from AccessControl import getSecurityManager, full_read_guard
 from zLOG import LOG, ERROR
+from ZCatalogIndexes import ZCatalogIndexes
 
 StringType=type('')
 
@@ -241,6 +242,11 @@
 
         self._catalog = Catalog(vocabulary=self.vocab_id)
 
+        indexes = ZCatalogIndexes('Indexes',vocabulary=self.vocab_id)
+        self._setObject('Indexes', indexes)
+
+        self._catalog.replaceIndexes(indexes)
+
         self._catalog.addColumn('id')
         self._catalog.addIndex('id', 'FieldIndex')
 
@@ -255,6 +261,8 @@
 
         self._catalog.addColumn('summary')
         self._catalog.addIndex('PrincipiaSearchSource', 'TextIndex')
+
+        self._catalog.addIndex('path','PathIndex')
 
     def __len__(self): return len(self._catalog)