[Product-Developers] prevent acquisition-wrapping for childs of dexterity types

Asko Soukka asko.soukka at iki.fi
Tue Jun 4 14:37:17 UTC 2013


Dominik wrote:
> http://developer.plone.org/reference_manuals/external/plone.app.dexterity/advanced/catalog-indexing-strategies.html
> mentions that
> "Objects are normally acquisition-wrapped when they are indexed, which means
> that an indexed value may be acquired from a parent. This can be confusing,
> especially if you are building container types and creating new indexes for
> them. If child objects don’t have attributes/methods with names
> corresponding to indexes, the parent object’s value will be indexed for all
> children as well."
> Is there a way to prevent this.

Define a custom indexer for your field, specific to your content type, 
and then define "a default indexer" to prevent indexing that field for 
any other type. Something like this should work as a default indexer::

     @indexer(Interface)
     def indexNothing(context):
         raise AttributeError
     grok.global_adapter(indexNothing, name="my_indexed_field")

So, just raising AttributError in matchinh indexer should prevent the 
field from being indexed.

-Asko


More information about the Product-Developers mailing list