Hi Martin!

Martin Aspeli wrote:
> yuppie wrote:
>> Martin Aspeli wrote:
>>> yuppie wrote:
>>>> AFAICS wrapping the object before looking up adapters is unnecessary. 
>>>> The catalog should do the lookup directly and the existing features 
>>>> provided by IndexableObjectWrapper should be reimplemented as adapters.
>>> Bear in mind that there is a difference between getting the wrapper 
>>> itself, and getting the value to catalogue for a particular *attribute* 
>>> of the wrapper (e.g. allowedRolesAndUsers).
>> Why do we need the wrapper? Why can't we look up directly the adapter 
>> for the particular attribute?
> This could work as well. It does make it harder to change the policy en 
> masse for a particular type (you'd need to override all the adapters, 
> say). One reason to do that may be if you have a very simple object that 
> you know exactly how to catalogue, and you don't want the overhead of 
> looking up various adapters.

I did have a closer look at this: The right place for looking up 
attribute specific adapters directly is deep in the ZCatalog code. And 
it might indeed be overkill to use separate adapters for several 
attributes of several content types.

So now I basically agree with the solution Miles and you did propose. 
But I still have some questions:

Why is IIndexableObjectWrapper in Plone a multi-adapter and not a simple 
adapter for object?

Could we push this further down the stack to the ZCatalog, making it 
unnecessary to override catalog_object in CMF? AFAICS all CMF-specific 
stuff could be done inside the wrapper.

> Still, the important use case, imho, is to make custom "indexers" for 
> your custom types. I quite like the pattern in plone.indexer where we 
> use an annotation to make a function into an indexer adapter:
> http://pypi.python.org/pypi/plone.indexer

I agree that's an important use case, but looking up 
IIndexableObjectWrapper based on the object provides already a solution 
for it. So we have a basic solution inside the framework and hook for 
plugging in alternative solutions like plone.indexer.



Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests

Reply via email to