|
From: Alec M. <al...@gm...> - 2014-10-24 14:34:49
|
If you're going to have a custom zcml registration, shouldn't that also do the wrapping? I guess that would get rid of the "advantage" of only one zcml registration, but it would also avoid the need to use the decorator at all. Perhaps both a zcml configuration and a corresponding grok directive would satisfy both those who want to do the registration from python and those who wish to keep it separate. On Fri, Oct 24, 2014 at 1:39 AM, Jens W. Klein <je...@bl...> wrote: > 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 > Plo...@li... > https://lists.sourceforge.net/lists/listinfo/plone-developers > |