|
From: Jens W. K. <je...@bl...> - 2014-10-24 08:40:06
|
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
|