Skip to content

Commit d7064f9

Browse files
Merge pull request #112 from plone/7.x-fix-searchabletext-indexer
Fix disabled SearchableText indexer [7.x]
2 parents 2007733 + ed9c86a commit d7064f9

25 files changed

Lines changed: 100 additions & 129 deletions

‎.github/workflows/tests.yml‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
python:
16-
- "3.8"
17-
- "3.9"
1816
- "3.10"
19-
- "3.11"
17+
- "3.13"
2018
plone:
2119
- "6.0-latest"
20+
- "6.1-latest"
2221

2322
steps:
24-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v6
2524

2625
- name: Setup Plone ${{ matrix.plone }} with Python ${{ matrix.python }}
2726
id: setup
28-
uses: plone/setup-plone@v1.0.0
27+
uses: plone/setup-plone@v3.0.0
2928
with:
3029
python-version: ${{ matrix.python }}
3130
plone-version: ${{ matrix.plone }}

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ src/
2525
/instance/
2626
/.make-sentinels/
2727
/*-mxdev.txt
28+
/.mxdev_cache
2829
/reports/
2930
/sources/
3031
/venv/

‎CHANGES.rst‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Changelog
44
7.0.2 (unreleased)
55
------------------
66

7-
- Nothing changed yet.
7+
- Fix ``IDynamicTextIndexExtender`` adapter registration and remove obsolete ``collective.textindexer`` checks.
8+
[petschki]
89

910

1011
7.0.1 (2023-11-16)

‎Makefile‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,7 @@ INSTANCE_FOLDER=instance
4747
PIP_PARAMS= --pre
4848

4949
##############################################################################
50-
# targets and prerequisites
51-
# target has to be one file, otherwise step gets executes for each file separate
52-
PREPARE_PREREQUISITES=${PIP_REQUIREMENTS_IN_FILE} ${CONSTRAINTS_IN} sources.ini ${ADDONBASE}setup.cfg
53-
PREPARE_TARGET=requirements-mxdev.txt
54-
INSTALL_PREREQUSISTES=${PREPARE_TARGET}
55-
INSTALL_TARGET=.installed.txt
56-
INSTANCE_PREREQUISITES=${INSTALL_TARGET} ${INSTANCE_YAML}
57-
INSTANCE_TARGET=${INSTANCE_FOLDER}/etc/zope.ini ${INSTANCE_FOLDER}/etc/zope.conf ${INSTANCE_FOLDER}/etc/site.zcml
58-
TEST_PREREQUISITES=${INSTALL_TARGET}
59-
RUN_PREREQUISITES=${INSTANCE_TARGET}
60-
61-
##############################################################################
62-
# CONVINIENCE
50+
# CONVENIENCE
6351

6452
# install and run
6553
.PHONY: all # full install, test and run
@@ -123,7 +111,7 @@ ifeq (, $(shell which $(PYTHON) ))
123111
endif
124112

125113
# version ok?
126-
PYTHON_VERSION_MIN=3.7
114+
PYTHON_VERSION_MIN=3.9
127115
PYTHON_VERSION_OK=$(shell $(PYTHON) -c 'import sys; print(int(sys.version_info[0:2] >= tuple(map(int, "$(PYTHON_VERSION_MIN)".split(".")))))' )
128116

129117
ifeq ($(PYTHON_VERSION_OK),0)

‎README.rst‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,19 @@ To make use of the page site layout, use the following:
143143

144144
See ``rendering.rst`` for detailed examples of how the processing is applied,
145145
and ``esi.rst`` for details about how Edge Side Includes can be supported.
146+
147+
148+
Indexing
149+
========
150+
151+
``plone.app.blocks`` provides a ``IDynamicTextIndexExtender`` adapter that extracts text from the blocks/tiles rendered within the content layout.
152+
This indexer adapter is only active when **both** of the following behaviors are enabled on the content type:
153+
154+
``plone.layoutaware``
155+
Enables the layout-aware content support (see above).
156+
157+
``plone.textindexer``
158+
Enables the extensible text indexing provided by ``plone.app.dexterity``.
159+
160+
If either behavior is missing, the ``SearchableText`` index will **not** include text from the rendered blocks.
161+
Make sure both behaviors are activated in the FTI (Factory Type Information) of your content type, for example via GenericSetup or the Dexterity control panel.

‎plone/app/blocks/__init__.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
from zope.i18nmessageid import MessageFactory
22

3-
43
PloneMessageFactory = MessageFactory("plone")

‎plone/app/blocks/configure.zcml‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -215,24 +215,9 @@
215215
zope.lifecycleevent.interfaces.IObjectModifiedEvent"
216216
handler=".subscribers.onLayoutEdited" />
217217

218-
<meta:provides feature="textindexer"
219-
zcml:condition="installed plone.app.dexterity.textindexer"
220-
/>
221-
222-
<meta:provides feature="textindexer"
223-
zcml:condition="installed collective.dexteritytextindexer"
224-
/>
225-
226-
<adapter
227-
name="SearchableText"
228-
factory=".indexing.LayoutSearchableText"
229-
zcml:condition="not-have textindexer"
230-
/>
231-
232218
<adapter
233219
name="content"
234220
factory=".indexing.LayoutSearchableTextIndexExtender"
235-
zcml:condition="installed collective.dexteritytextindexer"
236221
/>
237222

238223
<adapter factory=".linkintegrity.BlocksDXGeneral" />

‎plone/app/blocks/indexing.py‎

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,16 @@
22
from plone.app.blocks.layoutbehavior import ILayoutAware
33
from plone.app.blocks.layoutbehavior import ILayoutBehaviorAdaptable
44
from plone.app.contenttypes import indexers
5+
from plone.app.dexterity.textindexer.interfaces import IDynamicTextIndexExtender
56
from plone.base.utils import safe_text
6-
from plone.indexer.decorator import indexer
77
from plone.tiles.data import ANNOTATIONS_KEY_PREFIX
88
from zope.annotation.interfaces import IAnnotations
99
from zope.component import adapter
1010
from zope.interface import implementer
1111

12-
13-
HAS_DEXTERITYTEXTINDEXER = False
14-
15-
try:
16-
from collective.dexteritytextindexer.interfaces import ( # noqa
17-
IDynamicTextIndexExtender,
18-
)
19-
20-
HAS_DEXTERITYTEXTINDEXER = True
21-
except ImportError:
22-
pass
23-
24-
try:
25-
from plone.app.dexterity.textindexer.interfaces import ( # noqa
26-
IDynamicTextIndexExtender,
27-
)
28-
29-
HAS_DEXTERITYTEXTINDEXER = True
30-
except ImportError:
31-
pass
32-
3312
concat = indexers._unicode_save_string_concat
3413

3514

36-
@indexer(ILayoutBehaviorAdaptable)
3715
def LayoutSearchableText(obj):
3816
text = [obj.id]
3917
try:
@@ -77,13 +55,11 @@ def LayoutSearchableText(obj):
7755
return concat(*set(text))
7856

7957

80-
if HAS_DEXTERITYTEXTINDEXER:
81-
82-
@implementer(IDynamicTextIndexExtender)
83-
@adapter(ILayoutBehaviorAdaptable)
84-
class LayoutSearchableTextIndexExtender:
85-
def __init__(self, context):
86-
self.context = context
58+
@implementer(IDynamicTextIndexExtender)
59+
@adapter(ILayoutBehaviorAdaptable)
60+
class LayoutSearchableTextIndexExtender:
61+
def __init__(self, context):
62+
self.context = context
8763

88-
def __call__(self):
89-
return LayoutSearchableText(self.context)()
64+
def __call__(self):
65+
return LayoutSearchableText(self.context)

‎plone/app/blocks/interfaces.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from zope.interface import Attribute
55
from zope.interface import Interface
66

7-
87
SITE_LAYOUT_RESOURCE_NAME = "sitelayout"
98
CONTENT_LAYOUT_RESOURCE_NAME = "contentlayout"
109

‎plone/app/blocks/layoutbehavior.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import json
3838
import logging
3939

40-
4140
logger = logging.getLogger("plone.app.blocks")
4241

4342

0 commit comments

Comments
 (0)