Skip to content

Commit

Permalink
Avoid acquiring blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli committed Jan 7, 2024
1 parent 259e160 commit f05928a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/plone/volto/indexers.py
Expand Up @@ -39,6 +39,7 @@ def image_field_indexer(obj):
@indexer(IDexterityContent)
def block_types_indexer(obj):
"""Indexer for all block types included in a page."""
obj = aq_base(obj)
block_types = set()
for block in visit_blocks(obj, obj.blocks):
block_type = block.get("@type")
Expand Down
12 changes: 12 additions & 0 deletions src/plone/volto/tests/test_indexers.py
Expand Up @@ -77,3 +77,15 @@ def test_nested_blocks(self):
self.portal.doc1.reindexObject(idxs=["block_types"])
brains = self.catalog(block_types="teaser")
self.assertEqual(len(brains), 1)

def test_block_types_not_acquired(self):
"""Ensure that block_types is not acquired"""
blocks = {
"1": {"@type": "image", "url": ""},
"2": {"@type": "teaser", "styles": {"align": "left"}},
}
self.portal.doc1.blocks = blocks
self.portal.doc1.reindexObject(idxs=["block_types"])
self.portal.doc1.invokeFactory("Image", "image-1")
brains = self.catalog(block_types="image")
self.assertEqual(len(brains), 1)

0 comments on commit f05928a

Please sign in to comment.