Extending list_searchable_text index

Hi,

We wish to extend the search capabilities of Samples listing view with customs fields (e.g. patient id and name).

This extension feature is already implemented through a custom adapter mechanism: Listing Searchable Text Index

I’ve added this adapter => registered it in configure.zcml

    <adapter
        for="bika.lims.interfaces.IAnalysisRequest"
        name="ListingSearchableTextProviderPatient"
        provides="bika.lims.interfaces.IListingSearchableTextProvider"
        factory="senaite.mymodule.adapters.listingsearchabletext.ListingSearchableTextProviderPatient"
    />

technically my task is absolutely same as mentioned @ramonski and @xispa here: #1666 Issue (Added adapter to extend listing_searchable_text index)

But the problem is that this adapter is never being called (__call__) or even initialized (__init__).

Adapters lookup method getAdapters((instance, catalog), IListingSearchableTextProvider) in bika.lims.catalog.indexers.__init__ returns an empty generator object.

Is there any scope (layer?) exist or any special way to register such an adapter? It feels like it is just not registered in Zope.

Config:
Senaite 2.x
Plone 5.2.4

regards,
–leo

@ramonski we’ve used your PR sample code from here 1666 PR
it doesn’t work for us because:

def get_searchable_text_tokens(instance, catalog_name,
                               exclude_field_names=None,
                               include_field_names=None):
...
    for name, adapter in getAdapters((instance, catalog), IListingSearchableTextProvider)
...

returns empty list of adapters. Initially, we thought that something was wrong with our adapter registration routine and it is out of visibility scope because our adapter __init__ never called.

But we found that problem with catalog variable if remove it __init__ method of our custom adapter fires and the adapter works fine.

We cannot debug why it fails WITH catalog variable because there are no exceptions raised. Or exception raised but intercepted somewhere silently :slight_smile:

maybe you can advise how to work it around?
thanks!

–leo

Problem solved by adding IBikaCatalogAnalysisRequestListing to provider’s adapters list:

@adapter(IAnalysisRequest, IBikaCatalogAnalysisRequestListing)
@implementer(IListingSearchableTextProvider)
class ListingSearchableTextProviderPatient(object):

    def __init__(self, context, catalog):
        self.context = context
        self.catalog = catalog
        self.patient = context.getField("Patient").get(self.context)

requested fix to the doc file: Issue #1860

thanx