[Zope] Catalog Awareness

Robert Rottermann robert@redcor.ch
Sun, 24 Mar 2002 20:25:33 +0100


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 )
>