문제

I am trying to update SearchableText on my dexterity type ("Resource"), to include file contents from child items, by adding this to resource.py:

@indexer(IResource)
def subFiles(obj):
    searchable_text = obj.SearchableText()

    for item in obj.getFolderContents({'portal_type': 'File'}, full_object=True):
        searchable_text += item.SearchableText()
    return searchable_text

grok.global_adapter(subFiles, name="SearchableText")

I know I need an event to update this, but believe I should be able to see the index modified by manually "clearing and rebuilding" from the ZMI, however no changes take place on the value of SearchableText for objects of this content type. I am not seeing any errors either, so I am not sure where the problem lies.

도움이 되었습니까?

해결책

Well, I did not recognise here, that you are using dexterity.

You need the dexteritytextindexer behavior: https://github.com/collective/collective.dexteritytextindexer

Enable this on your container type.

<property name="behaviors">
    <element value="collective.dexteritytextindexer.behavior.IDexterityTextIndexer" />
</property>

With the dexteritytextindexer you have a different approach to index the data on your container. Check the dexteritytextindexer.IDynamicTextIndexExtender.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top