Re: Registering an indexer for multiple types

Jean Jordaan <[email protected]>
Newsgroups gmane.comp.web.zope.plone.devel
Message-ID <CAJqnznBZQiAbh-9RkXhK9WkXBX7GTX=xopDdqhFRCAy4N8zMmw@mail.gmail.com>
On Thu, Oct 23, 2014 at 10:27 PM, Alec Mitchell <apm13-WLbs8XpHrcb2fBVCVOL8/[email protected]> wrote:
> I don't think this is a bug per se, nor is it likely easily fixable.  Note
> that actual adapter registration is done in zcml, the decorator simply wraps
> the function and add a _default_ context interface for the adapter.  To get
> adapters registered for different interfaces you will always need to perform
> multiple zcml (or grok) registrations, performing multiple function
> wrappings is neither useful nor necessary for this purpose.

When you explain it that way, it makes sense, but from my perspective
as a user I have zero concern with the fact that multiple function
wrappings are happening. My goal isn't wrapping functions. It's the
right way to say "index all these types with this function". I found a
way, but it feels so wrong :-p

I experimented with making the decorator use the un-wrapped function,
when it gets called the second and subsequent times, but failed. Maybe
it could make a copy of the function? My component-fu is too weak.

> You should be able to simplify a bit though:
...
> <adapter name="getCountry" factory=".extender.country_indexer"
> for="Products.ATContentType.interfaces. IATFile" />

If I do this, I don't see the indexer being called for the interfaces
specified by the `for="..."` attribute. Only for the
`@indexer()`-specified interface.

-- 
jean                                              . .. .... //\\\oo///\\

------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.