zms-publishing / ZMS

Running on Python 3.8+
11 stars 5 forks source link

Catalog-Adapter: custom filter-function #248

Closed zmsdev closed 4 months ago

zmsdev commented 4 months ago

Ref: https://github.com/idasm-unibe-ch/unibe-cms-opensearch/issues/21

The indexing filter consists of python code that works with two parameters:

  1. context is the currently iterated object to be indexed
  2. meta_ids is the list of content-classes that should be indexed.

The applied code can define rules based on the context's attributes values whether indexing shall happen or not. The returning value of the filter rules must be True or False. A simple example will illustrate how it can be applied; the intention would be "Do not index any inactive node, it's descendants and nodes having type-attribute set to 'Resource'".

##
return (context.meta_id in meta_ids) \
  and not [ob for ob in context.breadcrumbs_obj_path() if not ob.isActive(context.REQUEST)] \
  and not context.attr('attr_dc_type')=='Resource'

default:

##
return context.meta_id in meta_ids
drfho commented 4 months ago

https://github.com/zms-publishing/ZMS/pull/248/commits/6bf390be2282b21a0983ffcbe3f2b5bdca3d8c1d https://github.com/zms-publishing/ZMS/pull/248/commits/a556960b555faf44f0c4a3bfcf0e15888e9f6da2

image