[Zope] CatalogAware ZClass with File base class

Kevin Dangoor kid@kendermedia.com
Tue, 2 May 2000 14:04:44 -0400


Take a look in your Zope installation at lib/python/OFS/Image.py, and you
can see the methods that are available for Files and Images.

Then, look in lib/python/Products/ZCatalog/ZCatalog.py and you can see the
ZCatalog methods.

All you need to do is have the method that accepts the file upload all
manage_addFile and then Catalog.catalog_object... You don't necessarily need
to deal with a CatalogAware ZClass. One thing to note, though, is that the
file won't automatically be removed from the catalog if it is deleted.

It seems like your ZClass idea could work, if you do want to guarantee that
the file gets removed from the catalog if it is deleted. I haven't
subclassed anything but CatalogAware and ObjectManager for my ZClasses,
though.

Kevin

----- Original Message -----
From: Fusion Group
To: Kevin Dangoor ; zope@zope.org
Sent: Monday, May 01, 2000 5:37 PM
Subject: Re: [Zope] CatalogAware ZClass with File base class


I might be barking up the wrong tree with my attempt to make file objects
catalogaware.  I have a separate ZClass that stores information about my
File Object (Article or Book) and creating instantiations of that ZClass
(with the proper code in my ZClass_add method, just like your example below)
works just fine.  I wanted to store my File Objects separate from my
information ZClass objects because a single information ZClass object might
define information for several file objects.

Really what this all comes down to is I need a way to programmatically add
File objects to my Catalog when a new file is uploaded so that it's
immediately available through the search engine.  Creating a ZClass with
base (File and CatalogAware) classes was the first thing I thought of, but
if there is any other way...