[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG - interactiveDemo.py:1.1.2.5

Andreas Jung andreas@digicool.com
Sun, 24 Feb 2002 08:13:59 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG
In directory cvs.zope.org:/tmp/cvs-serv31532

Modified Files:
      Tag: ajung-textindexng-branch
	interactiveDemo.py 
Log Message:
now supporting full functionality of TextIndexNG through Catalog schimera


=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/interactiveDemo.py 1.1.2.4 => 1.1.2.5 ===
 from Products.PluginIndexes.TextIndexNG import TextIndexNG
 from Products.PluginIndexes.TextIndex import TextIndex
-from Products.ZCatalog import Catalog
+from Products.ZCatalog.Catalog import Catalog
 import os, sys, re,traceback, atexit, getopt
 import time
-import readline
 from optik import OptionParser
 
-histfile = os.path.expanduser('~/.pyhist')
 try:
+    import readline
+    histfile = os.path.expanduser('~/.pyhist')
     readline.read_history_file(histfile)
-except IOError: pass
-atexit.register(readline.write_history_file,histfile)
+    atexit.register(readline.write_history_file,histfile)
+except: pass
 
 
 class TO(ExtensionClass.Base):
@@ -24,11 +24,23 @@
         self.path = path
 
 
+class TestCatalog(Catalog):
+        
+    _objects = {}
+
+    def catalogObject(self, obj, uid):
+        Catalog.catalogObject(self, obj, uid)
+        self._objects[uid] = obj
+        
+    def unrestrictedTraverse(self, path):
+        return self._objects[path]
+
+
 def index_directory(dirname, extra, verbose, timed, old):
 
     if not dirname: raise RuntimeError,'no directory name'
 
-    CAT = Catalog.Catalog("cat")
+    CAT = TestCatalog("cat")
     CAT.aq_parent = TO('aq_parent')
 
     if old:
@@ -39,6 +51,8 @@
         if verbose: TI.debugOn()
         else:       TI.debugOff()
         TI.timed_statistics = timed
+
+    TI.catalog = CAT
 
 
     CAT.addIndex('text',TI)