[Product-Developers] Re: how to prevent portal_catalog from indexing acquisition values?

Martin Aspeli optilude+lists at gmail.com
Sat Apr 18 04:23:32 UTC 2009


Andreas Jung wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 17.04.2009 15:37 Uhr, Kees Hink wrote:
>> I have a field 'performance_code', which i want to create catalog indexes for.
>>
>> Problem is that objects contained in objects of my content type will acquire the
>> value of its parent, so catalog queries for 'getPerformance_code' will also
>> return brains for objects which don't actually have that field.
>>
>> I tried setting 'index_method = context.aq_explicit().performance_code' in the
>> schema, to no effect.
>>
>> What to do?
>>
> 
> Create a method foo() within your class and create an index called
> 'foo'. Within foo() you can add your code taking care about acquisition.

Or, if you're on plone 3.3, use a custom indexer that does the 
aq_explicit check.

See plone.indexer on pypi for instructions or the PLIP page on plone.org

Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book





More information about the Product-Developers mailing list