Ticket #20054 (confirmed Bug)

Opened 17 months ago

Last modified 17 months ago

Cataloging multiple types under one index using plone.indexer

Reported by: neaj Owned by:
Priority: major Milestone: 4.x
Component: General Version: 4.2
Keywords: Cc:

Description

In configure.zcml I have:

<adapter name="getCountry" factory=".extender.country_indexer" />

In extender.py I have:

@indexer(IATFile)
@indexer(IATImage)
@indexer(IProject)
@indexer(IATDocument)
def country_indexer(context):
    return _country_indexer(context)

But this does not catalog all those types under the getCountry index.

If I comment out all but one decorator, it works for that type.

On *plone-dev*, jensens states "i'd consider that as conceptional a bug with the decorator."

Change History

comment:1 Changed 17 months ago by neaj

  • Priority changed from minor to major
  • Component changed from Unknown to General

comment:2 Changed 17 months ago by neaj

Some more info. Only one of the registrations is called with the proper callable. The others are called with DelegatingIndexerFactory:

indexer.__init__ <plone.indexer.decorator.indexer instance at 0xafa6998> (<InterfaceClass Products.ATContentTypes.interfaces.file.IATFile>,)
indexer.__init__ <plone.indexer.decorator.indexer instance at 0xafa6f80> (<InterfaceClass Products.ATContentTypes.interfaces.image.IATImage>,)
indexer.__init__ <plone.indexer.decorator.indexer instance at 0xafa8050> (<InterfaceClass iwlearn.project.interfaces.project.IProject>,)
indexer.__init__ <plone.indexer.decorator.indexer instance at 0xafa8128> (<InterfaceClass Products.ATContentTypes.interfaces.document.IATDocument>,)
indexer.__call__ <plone.indexer.decorator.indexer instance at 0xafa8128> <function country_indexer at 0xafa76e0>
indexer.__call__ <plone.indexer.decorator.indexer instance at 0xafa8050> <plone.indexer.delegate.DelegatingIndexerFactory object at 0xafa5910>
indexer.__call__ <plone.indexer.decorator.indexer instance at 0xafa6f80> <plone.indexer.delegate.DelegatingIndexerFactory object at 0xafa5b90>
indexer.__call__ <plone.indexer.decorator.indexer instance at 0xafa6998> <plone.indexer.delegate.DelegatingIndexerFactory object at 0xafa5910>

comment:3 Changed 17 months ago by neaj

From jensens in  http://sourceforge.net/p/plone/mailman/message/32965851/

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" />
Last edited 17 months ago by neaj (previous) (diff)

comment:4 Changed 17 months ago by cwainwright

  • Status changed from new to confirmed

Marking ticket as confirmed to get it out of the pile o' spam

Note: See TracTickets for help on using tickets.