[Zope] How to catalog ExtFile objects with TextIndexNG2?
nicogrubert at arcor.de
nicogrubert at arcor.de
Thu Sep 23 05:01:35 EDT 2004
Hi there,
I have written a class called 'DZ_Document' which is derived from File to create File objects in Zope
with a few additional attributes like 'group', 'author', 'keywords' and so on.
I would like to catalog the new attributes as well as the file content of the uploaded file (e.g. a PDF document)
to provide a full text search.
I have created a ZCatalog 'DZCatalog' with an Index named 'SearchableText' of type 'TextIndexNG2'. In the
attributes field of this index I wrote:
SearchableText,data,id,group,author,keywords
TextIndexNG2 works fine if I index objects of type 'File' (e.g. PDF documents) into my
ZCatalog 'DZCatalog' using the "Find and Catalog" Tab of the ZCatalog. But when I try to index 'ExtFile' objects (for a quick test I was using the "Find and Catalog" Tab of the ZCatalog) I am prompted with a "Save as" Window to save the found ExtFile to my local hard drive.
Here is a short Code snippet of my current application:
####################
class DZ_Document( File, CatalogAware ):
"""
Derive DZ_Document class from File class to provide some more attributes
for storing information like group, etc.
"""
def __init__(self, id, title, file, group):
" class constructor "
File.__init__(self, id, title, file)
self.group = group
# automatically set attributes
self.filesize = self.printSize()
self.filetype = self.content_type
...
def manage_addDZ_Document(self, file, id, group, title='', REQUEST=None):
" add DZ_Document Object to Zope "
content_type = ''
newObj = DZ_Document(id, title, file, group )
Documents_Folder = self._getOb('Documents')
Documents_Folder._setObject(id, newObj)
_realObj = Documents_Folder._getOb(id)
_realObj.manage_upload(file) # manage_upload is defined in class 'File'
_realObj.default_catalog = "DZCatalog"
_realObj.index_object()
if REQUEST is not None:
REQUEST['RESPONSE'].redirect('manage_main')
####################
My goal is, to rewrite the application so I can create and index 'ExtFile' objects instead of 'File' objects in Zope. My applications works very well if I index objects of type "File", but how do I avoid this "Save as" Window when Zope tries to index an ExtFile objects in the ZCatalog?
Thank you in advance,
Nico
Arcor-DSL: jetzt ohne Einrichtungspreis einsteigen oder wechseln
Sie sparen 99,95 Euro. Arcor-DSL ist in vielen Anschlussgebieten
verfügbar. http://www.arcor.de/home/redir.php/emf-dsl-1
More information about the Zope
mailing list