#239: Adapterise the Extensible Indexable Object Wrapper
- Contents
Make it easier to register ExtensibleIndexableObjectWrapper attributes with adapters
- Proposed by
- Martin Aspeli
- Proposal type
- Architecture
- Assigned to release
- State
- completed
Motivation
Custom indexing strategies currently rely on a global registry of "fake" attributes to the indexable object wrapper. It would be more natural and flexible to be able to register adapters for any context that can provide values for indexable attributes.
Proposal
- Create a new package, plone.indexer
- Here, define an interface, IIndexer, which looks like this:
class IIndexer(Interface): def __call__(self): """Return the value to index. """
The idea is that you register an adapter that adapts your content type (self.context) and the catalog (self.catalog) and provides IIndexer, with the name of the indexable attribute. - Create a convenience @indexer decorator to allow simpler indexers like the following:
@indexer(IMyType) def my_indexer(object): return ...
- Create a standard IndexableObjectWrapper implementation that looks up such adapters when asked to provide indexable attributes.
- Update CMFPlone's CatalogTool to use this wrapper
- Deprecate registerIndexableAttribute() and make it register delegate adapters for now.
Risks
We may find that doing an adapter lookup for each attribute that gets indexed is slower than finding a function in a global dict, as it is now. Hopefully, the zope.component cache will solve this, but we should benchmark.
Progress log
- plone.indexer written and tested
- Plone branch created and relevant tests updated
- BBB code in place
- Deprecate plone.app.content.interfaces.IIndexableObjectWrapper as an alias for plone.indexer's version of the same (we can do this post-merge)


For example, if you take many objects that are based on the same class, if they have no 'directlyProvided' interfaces (a.k.a. marker interfaces) there's no reason at all for the lookup to be different between two random objects of this set. Maybe the adapter lookup can be short-lived and cached at a higher level, closer to the place where this is used, when indexing/reindexing many objects.