Plone 4: Can't override Description indexer (plone.app.discussion, IComment)

I have a Plone 4.3 site, and I'd like to override the Description indexer; I have a function to extract the first NNN visible characters from HTML text, preserving selected HTML tags (excluding href attributes etc.). I'd like to use this "head" (after the console program) for my Description metadata.

However, Description and some other indexers are defined by plone.app.discussion, for the IComment interface, which also contains schema fields.

When I simply define my indexer, using a dedicated interface (just for this purpose), it is not used; the indexer from plone.app.discussion always wins.

When I make my interface inherit from plone.app.discussion.interfaces.IComment instead of zope.interface.Interface, it is used; but apparently all other indexers defined for the IComment interface are tried as well, and this causes trouble; the existence of all the other fields defined in the schema is assumed, which don't exist for my non-comment AT content types.

So, what can I do?

  • Is there a way to reliably override an indexer? (I tried to use my browser layer, but this seems not to work for adapters)
  • Would I need a new version of plone.app.discussion which uses a dedicated interface just for the indexers, separated from the IComment interface which contains the schema?

If the indexer is registered through ZCML you could always use the overrides.zcml 'escape hatch' to patch an existing registration.

Thank you; I'll try this.

Plone Foundation Code of Conduct