[Zope] Obtaining the index (data) from a TextIndex (ZCatalog)

complaw_rm_@hal-pc.org complaw_rm_@hal-pc.org
Wed, 8 Jan 2003 00:02:54 GMT


Is there a way to get the entire list of words from the data property of a
ZCatalog's TextIndex?

I'm trying to obtain the list of words from a TextIndex.  In this case, the list
of words are very instructive for the client.  The idea is to load up a bunch of
documents, and then use the ZCatalog to get a list of words in the various
documents.  We are looking for technical terms (that we don't know a priori). 
Is there a way to do that?

A review of the TextIndex.py source indicates that the TextIndex class has a
_data property that contains the list of words.  The problem is getting at that
property.  For example, the following code:

S = ''
lst = []

if container.abstract_tracker.Indexes:
  lst = container.abstract_tracker.Indexes.PrincipiaSearchSource.data
  S = 'Found it'
else:
  S = 'Not there'

return S

Prompts the following error message...

Traceback (innermost last):
  File /usr/local/zope/2-4-3/lib/python/ZPublisher/Publish.py, line 223, in
publish_module
  File /usr/local/zope/2-4-3/lib/python/ZPublisher/Publish.py, line 187, in publish
  File /usr/local/zope/2-4-3/lib/python/Zope/__init__.py, line 226, in
zpublisher_exception_hook
    (Object: ncr)
  File /usr/local/zope/2-4-3/lib/python/ZPublisher/Publish.py, line 171, in publish
  File /usr/local/zope/2-4-3/lib/python/ZPublisher/mapply.py, line 160, in mapply
    (Object: obtain_index)
  File /usr/local/zope/2-4-3/lib/python/ZPublisher/Publish.py, line 112, in
call_object
    (Object: obtain_index)
  File /usr/local/zope/2-4-3/lib/python/Shared/DC/Scripts/Bindings.py, line 324,
in __call__
    (Object: obtain_index)
  File /usr/local/zope/2-4-3/lib/python/Shared/DC/Scripts/Bindings.py, line 354,
in _bindAndExec
    (Object: obtain_index)
  File /usr/local/zope/2-4-3/lib/python/Products/PythonScripts/PythonScript.py,
line 363, in _exec
    (Object: obtain_index)
    (Info: ({'script': <PythonScript instance at 9726880>, 'context': <Folder
instance at 9cab578>, 'container': <Folder instance at 9cab578>,
'traverse_subpath': []}, (), {}, None))
  File Script (Python), line 5, in obtain_index
    (Object: guarded_getattr)
  File /usr/local/zope/2-4-3/lib/python/AccessControl/ZopeGuards.py, line 109,
in guarded_getattr
    (Object: )
AttributeError: (see
above)