Adapters are only searched one deep, so you need to register each adapter path separately. I use this function as a helper:

from zope.component import provideAdapter

def provideAdapterChain(adapt_from, *chain):
    Register an adapter chain
    adapt_from is the interface that is adapted from
    chain is the chain of interfaces that should be walked
        providAdapterChain(IA, IB, IC)

    return provideAdapter(
lambda adaptee: reduce(lambda ob, iface: iface(ob), chain, adaptee),
        provides = chain[-1])


Frank Burkhardt wrote:

I've got objects implementing interface

and two adapters:

 IMyObject -> ISearchable
 ISearchable -> ISearchableEN

I would like to use a TextIndex to do fulltext search on objects
implementing ISearchableEN .
Unfortunately this doesn't work. The TextIndex tries something
like this to adapt an object to the given interface:


Which fails ("Unable to adapt") because there is no adapter
"IMyObject -> ISearchableEN" and Zope doesn't try to adapt multiple
times ( IMyObject -> ISearchable -> ISearchableEN ).

Does anyone have an Idea how to do this or do I have to modify
the TextIndex?



Zope3-users mailing list

Reply via email to