Hi, I have a need to modify a Zope product so that at least one of it's classes becomes catalog aware. All the documentation I can find on catalog awareness refers to building ZClasses and giving them this feature; but the product I need to modify is built with external python code that resides in the "Products" directory. I understand though that it is possible for a product to be built which is a hybrid of Python code and ZClasses. So perhaps it is possible? Right now I'm having to use a workaround that changes the properties of a dtml document each time I need to catalog a new item of the product class concerned. I then re-catalog the same dtml document with the new properties; but this is taking to much of a toll on performance. Can anyone advise me on this? Thanks geoff
Hi Geoff, I wrote a product CatalogAwareProperties: http://www.zope.org/Members/Dirk.Datzert/CatalogAwareProperties Test it, if it fits your needs. Regards, Dirk Geoff Armstrong schrieb:
Hi,
I have a need to modify a Zope product so that at least one of it's classes becomes catalog aware.
All the documentation I can find on catalog awareness refers to building ZClasses and giving them this feature; but the product I need to modify is built with external python code that resides in the "Products" directory. I understand though that it is possible for a product to be built which is a hybrid of Python code and ZClasses. So perhaps it is possible?
Right now I'm having to use a workaround that changes the properties of a dtml document each time I need to catalog a new item of the product class concerned. I then re-catalog the same dtml document with the new properties; but this is taking to much of a toll on performance.
Can anyone advise me on this?
Thanks
geoff
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
hi geoff, add the following methods (they are from Zwiki) and call self.reindex() each time you change something the code assumes that a catalog called 'Catalog' can be aquired. Robert def getCatalogId(self): """Return the name of the catalog used by this document""" return getattr(self, 'Catalog') def url(self): """Return the absolute object path""" return string.join(self.getPhysicalPath(),'/') def index_object(self): """A common method to allow Findables to index themselves.""" if hasattr(self, self.getCatalogId()) and \ not getattr(self, 'NOT_CATALOGED', 0): #sys.stderr.write( 'INDEXING PAGE!' +'\n') #SKWM getattr(self, self.getCatalogId()).catalog_object(self, self.url()) self.is_indexed_ = 1 #sys.stderr.write( 'INDEX DONE!' +'\n') #SKWM def unindex_object(self): """A common method to allow Findables to unindex themselves.""" #sys.stderr.write( 'UNINDEX_OBJECT!' +'\n') #SKWM if hasattr(self, self.getCatalogId()): getattr(self, self.getCatalogId()).uncatalog_object(self.url()) self.is_indexed_ = 0 def reindex_object(self): """Reindex the object in the Catalog""" if getattr(self, 'is_indexed_', 0): self.unindex_object() self.index_object() ----- Original Message ----- From: "Geoff Armstrong" <geofstro@monaco.mc> To: <zope@zope.org> Sent: Sunday, March 24, 2002 8:04 PM Subject: [Zope] Catalog Awareness
Hi,
I have a need to modify a Zope product so that at least one of it's classes becomes catalog aware.
All the documentation I can find on catalog awareness refers to building ZClasses and giving them this feature; but the product I need to modify is built with external python code that resides in the "Products" directory. I understand though that it is possible for a product to be built which is a hybrid of Python code and ZClasses. So perhaps it is possible?
Right now I'm having to use a workaround that changes the properties of a dtml document each time I need to catalog a new item of the product class concerned. I then re-catalog the same dtml document with the new properties; but this is taking to much of a toll on performance.
Can anyone advise me on this?
Thanks
geoff
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Geoff Armstrong wrote:
Hi,
I have a need to modify a Zope product so that at least one of it's classes becomes catalog aware.
It is not difficult. The ZClass documentation is valid for a python product, too: You need to: 1. Subclass from CatalogAware: "class myClass(..., CatalogAware)" 2. insert default_catalog="yourCatalog" to your Class you want to index. 3. call self.index_object() every time you change your data I hope I have not forgotten a step thomas
Well, I forgot the obvious. Of course I needed to do "import from Products.ZCatalog.CatalogAwareness import CatalogAware". Now the product no longer complains that it's broken when I subclass "CatalogAware" in each of it's classes that I want to be catalog aware. So far so good; but I'm still not getting automatic cataloging of these classes objects. Can anyone advise, what's the next obvious thing I'm missing? Also, out of a hierarchy of 3 classes, it's the last of these that I really want to get into my catalog (automatically); but it is a non persistent/transient class. I want to be able to auto catalog each instance of this class in my catalog and keep it there after the instance goes away. Is this possible? If not, how can I get to it's properties via it's (catalog aware) parents class and (automatically) index those? I somehow feel this should be possible; but still can't quite see how to achieve it. Can anyone enlighten me further? geoff
participants (4)
-
Dirk Datzert -
Geoff Armstrong -
Robert Rottermann -
Thomas Guettler