Re: Registering an indexer for multiple types

"Jens W. Klein" <jens-/[email protected]>
Newsgroups gmane.comp.web.zope.plone.devel
Organization Klein & Partner KG
Message-ID <[email protected]>
On 2014-10-23 16:27, Alec Mitchell 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.  You should be able to simplify a bit though:
>
> in python:
>
> @indexer(IATDocument)
> def country_indexer(context):
>      return _country_indexer(context)
>
> in zcml:
>
> <adapter name="getCountry" factory=".extender.country_indexer" />
> <adapter name="getCountry" factory=".extender.country_indexer"
>   for="Products.ATContentType.interfaces. IATFile" />
> …
>
indeed.

in order to make this work with one node in zcml it would need an own 
zcml-directive registering multiple adapters and a different way to 
annotate the interfaces to be adapted:

@indexer(IATDocument)
@indexer(IATNewsItem)
def country_indexer(context):
      return _country_indexer(context)

in zcml:

<indexer:register
     name="getCountry"
     factory=".extender.country_indexer" />

OR

@indexer(IATDocument, 'getCountry')
@indexer(IATNewsItem, 'getCountry')
def country_indexer(context):
      return _country_indexer(context)

(second parameter could be optional and default to the function name)

in zcml:

<indexer:register factory=".extender.country_indexer" />


Jens
-- 
Klein & Partner KG, member of BlueDynamics Alliance


------------------------------------------------------------------------------
_______________________________________________
Plone-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plone-developers
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.