CatalogAware ZClass with File base class
I wanted to make my new File objects CatalogAware so I created a new ZClass with CatalogAware and File as my base classes (in that order). When I upload a new file, calling manage_addFile from my ZClass, it of course is not made available for my Catalog. I know I'm doing this wrong, but I'm starting to run out of time on this project and can't afford the luxury of fiddling until I figure it out anymore. I probably should have fiddled with Zope a little before I used it for a client's project, but it's too late now. Any help would be greatly appreciated Regards, Chad
Caveat: I've never made a ZClass with File as a base class... I just thought I would double check that in your ZClass_add method, you do this: <dtml-with "createInObjectManager..."> <dtml-call "propertysheet.YourPropSheet.manage_editProperties(REQUEST)"> <dtml-call reindex_object> </dtml-with> If you don't store the properties and reindex the object, the object will be added to the catalog but won't be particularly useful because there won't be any values for the properties stored in the indexes and meta data. Kevin ----- Original Message ----- From: Fusion Group To: zope@zope.org Sent: Monday, May 01, 2000 4:27 PM Subject: [Zope] CatalogAware ZClass with File base class I wanted to make my new File objects CatalogAware so I created a new ZClass with CatalogAware and File as my base classes (in that order). When I upload a new file, calling manage_addFile from my ZClass, it of course is not made available for my Catalog. I know I'm doing this wrong, but I'm starting to run out of time on this project and can't afford the luxury of fiddling until I figure it out anymore. I probably should have fiddled with Zope a little before I used it for a client's project, but it's too late now.
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... If you have any ideas... I appreciate your help. Best Regards, Chad ----- Original Message ----- From: Kevin Dangoor To: Fusion Group ; zope@zope.org Sent: Monday, May 01, 2000 3:06 PM Subject: Re: [Zope] CatalogAware ZClass with File base class Caveat: I've never made a ZClass with File as a base class... I just thought I would double check that in your ZClass_add method, you do this: <dtml-with "createInObjectManager..."> <dtml-call "propertysheet.YourPropSheet.manage_editProperties(REQUEST)"> <dtml-call reindex_object> </dtml-with> If you don't store the properties and reindex the object, the object will be added to the catalog but won't be particularly useful because there won't be any values for the properties stored in the indexes and meta data. Kevin ----- Original Message ----- From: Fusion Group To: zope@zope.org Sent: Monday, May 01, 2000 4:27 PM Subject: [Zope] CatalogAware ZClass with File base class I wanted to make my new File objects CatalogAware so I created a new ZClass with CatalogAware and File as my base classes (in that order). When I upload a new file, calling manage_addFile from my ZClass, it of course is not made available for my Catalog. I know I'm doing this wrong, but I'm starting to run out of time on this project and can't afford the luxury of fiddling until I figure it out anymore. I probably should have fiddled with Zope a little before I used it for a client's project, but it's too late now.
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...
participants (2)
-
Fusion Group -
Kevin Dangoor