[Zope] stopping indexing of acquired attributes

Chris Withers chrisw@nipltd.com
Tue, 31 Dec 2002 10:33:11 +0000


Luca Olivetti wrote:
> I stumbled into another problem: the method is useable for indexes but 
> not for metadata.
> I digged into the source of ZCatalog and I saw that's because Zcatalog 
> first calls recordify (see Catalog.py) on the object which uses MV (from 
> Missing) to indicate a missing attribute, while each plugin index uses a 
> different method to identify a missing attribute (for example, 
> UnIndex.py defines an internal _merker as []).

Why would hypothesise that the real problem is that adding stuff to indexes 
ignores AttributeError's and KeyError's which storing it as metadata doesn't, 
which it should.

> So if my method uses
> 
>    attr=getattr(context.aq_explicit,'myattribute')
> 
> it will tipically work in a plugin index because it's wrapped in a try 
> except block, but will not work with metadata since there's no 
> try/except there.

So put one in yourself ;-) (well, something that works the same...)

attr=getattr(context.aq_explicit,'myattribute',None)

I think that's your best bet...

cheers,

Chris