[Zope] stopping indexing of acquired attributes

Luca Olivetti luca@wetron.es
Mon, 30 Dec 2002 15:57:07 +0100


Chris Withers wrote:

Thanks! you put me on the right track

> I would index the actual attribute, I'd index something called 

s/would/wouldn't/  I suppose ;-)

> index_yourattributename. Then define a method called 
> 'index_yourattributename' as follows:
> 
> return getattr(context.aq_explicit,'yourattributename')

Ok, the key is *not* to define the method inside the class.
To wrap it up in case someone searches the list:

1) define a python script somewhere in the acquisition path where the 
catalog  will pick it up. Since mine is a CMF Product I used the skin 
directory. Call it, e.g., index_yourattribute

2) the content of the script is

attr=getattr(context.aq_explicit,'yourattributename')
if callable(attr): attr=attr()
return attr

3) define an index and/or metadata called like the python script 
(index_yourattribute)

4) enjoy :-)


Bye
-- 
Luca Olivetti
Wetron Automatización S.A. http://www.wetron.es/
Tel. +34 93 5883004      Fax +34 93 5883007