From f05928ae0580110d133e405d4b58109b363293ba Mon Sep 17 00:00:00 2001 From: David Glick Date: Sat, 6 Jan 2024 17:36:54 -0800 Subject: [PATCH 1/8] Avoid acquiring blocks --- src/plone/volto/indexers.py | 1 + src/plone/volto/tests/test_indexers.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/plone/volto/indexers.py b/src/plone/volto/indexers.py index 8ee37aa9..de29b524 100644 --- a/src/plone/volto/indexers.py +++ b/src/plone/volto/indexers.py @@ -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") diff --git a/src/plone/volto/tests/test_indexers.py b/src/plone/volto/tests/test_indexers.py index c004159e..b8456aac 100644 --- a/src/plone/volto/tests/test_indexers.py +++ b/src/plone/volto/tests/test_indexers.py @@ -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) From 5c8f809831179148578215534d99416ee969dbd5 Mon Sep 17 00:00:00 2001 From: David Glick Date: Sat, 6 Jan 2024 17:38:16 -0800 Subject: [PATCH 2/8] changelog --- news/137.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/137.bugfix diff --git a/news/137.bugfix b/news/137.bugfix new file mode 100644 index 00000000..a7f5e23e --- /dev/null +++ b/news/137.bugfix @@ -0,0 +1 @@ +Avoid accidental acquisition in block_types indexer. @davisagli From 78a6ff8d6e54aafd7f07e4bdade5fccfbd2a5f05 Mon Sep 17 00:00:00 2001 From: David Glick Date: Sat, 6 Jan 2024 17:43:11 -0800 Subject: [PATCH 3/8] mention the block_types index in the readme --- README.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.rst b/README.rst index 06ab223f..c78af32b 100644 --- a/README.rst +++ b/README.rst @@ -94,6 +94,19 @@ Volto Blocks Support plone.volto enables the new Volto Blocks editor on ``Document``, ``Language Root Folder`` and ``Site Root``. +Block Types Index +----------------- + +plone.volto adds a ``block_types`` index to the Plone catalog. +It can be used to query for items that use a particular type of block:: + + portal_catalog.searchResults(block_types="image") + +The ``block_types`` index was added in plone.volto 4.1.0. +By default it is only added for new Plone sites. +To add it to an existing site, run ``plone.volto.upgrades.add_block_types_index`` manually. + + Multilingual Support -------------------- From 1248f658a615d111cc837d4af88089a9e3eeae67 Mon Sep 17 00:00:00 2001 From: David Glick Date: Sun, 7 Jan 2024 19:30:32 -0800 Subject: [PATCH 4/8] sentence case for all headings --- README.rst | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.rst b/README.rst index c78af32b..ed524620 100644 --- a/README.rst +++ b/README.rst @@ -55,7 +55,7 @@ You can still use 2.x in p.restapi 7.0.0 based installations but the transforms Volto only supports the latest plone.restapi branch, therefore it is recommended to always use the latest version in your Volto projects. -Plone 6 Architecture +Plone 6 architecture ==================== Architectural Diagram of Plone 6:: @@ -88,13 +88,13 @@ Features plone.volto provides the following features: -Volto Blocks Support +Volto blocks support -------------------- plone.volto enables the new Volto Blocks editor on ``Document``, ``Language Root Folder`` and ``Site Root``. -Block Types Index +Block types index ----------------- plone.volto adds a ``block_types`` index to the Plone catalog. @@ -107,7 +107,7 @@ By default it is only added for new Plone sites. To add it to an existing site, run ``plone.volto.upgrades.add_block_types_index`` manually. -Multilingual Support +Multilingual support -------------------- plone.volto supports multilingual websites. @@ -115,7 +115,7 @@ Install PAM before installing this package and demo homepages will be created in Currently only support for EN/DE. -Volto Blocks for Plone Site Root +Volto blocks for Plone site root -------------------------------- plone.volto contains a hack to make the Plone site Volto blocks-enabled with some demo content. @@ -141,7 +141,7 @@ corresponding Language Root Folders) is "draftJS" text block. ``plone.volto`` pr profile if you want to create Slate blocks: you need to use the ``default-homepage-slate`` profile. -Document Content Type +Document content type --------------------- plone.volto disables the ``Richtext`` and ``Table of Contents`` behaviors for the ``Document`` content type. @@ -149,7 +149,7 @@ Rich Text functionality is provided by the new Volto Blocks editor. The ``Table of Contents`` functionality is provided by the ``Table of Contents Block`` in Volto. -CORS Profile +CORS profile ------------ A quick helper for enable CORS for development config is also provided in the @@ -165,7 +165,7 @@ productions sites. It's planned that Volto will feature a development pass-through proxy to the backend in the future. It will be addressed in next sprints. -ZLog Patch +ZLog patch ---------- p.restapi low level errors are routed through the ancient ZLog and are ``plone_error`` @@ -174,7 +174,7 @@ using helpers like Sentry. This patch removes the UUID so the same error is cate all together. This is planned to be addressed in next sprints. -Patch for ``subject`` Field +Patch for ``subject`` field --------------------------- There are some problems of serialization on special characters derivated from how the @@ -183,7 +183,7 @@ addressed in order to make it work properly with Volto (and other systems that a Plone). This will be fixed in core in upcoming sprints. -Preview Image Behavior +Preview image behavior ---------------------- The preview image behavior makes content types provide a ``preview_image`` field that can store a preview image that Volto views can pick up. @@ -208,7 +208,7 @@ The ``volto.preview_image`` behavior can be enabled in the generic setup XML def There is also another variation of the preview image behavior called ``volto.preview_image_link``. This one stores preview images using a relation to an Image content type, rather than in an image field. This might be preferable if many content items use the same preview image. -Navigation Title Behavior +Navigation title behavior ------------------------- The navigation title makes content types provide a nav_title field that is used by Volto in the main navigation, the breadcrumbs and the navigation portlet. @@ -230,7 +230,7 @@ The "volto.navtitle behavior can be enabled in the generic setup XML definition -Head Title Behavior +Head title behavior ------------------- The headtitle makes content types provide a headtitle field that can be used by Volto in teasers and alikes. @@ -252,7 +252,7 @@ The "volto.head_title" behavior can be enabled in the generic setup XML definiti -Image Scales +Image scales ------------ This package introduces new Plone image scales in Plone and redefines a couple of @@ -273,7 +273,7 @@ existing ones. These are know to work well with Volto layout and grid system:: sure your add-on's profiles are applied AFTER this one.** -Credits and History +Credits and history ------------------- .. image:: https://kitconcept.com/logo.svg From c625502afbc0271feefbce8fb89dac7ac417577a Mon Sep 17 00:00:00 2001 From: David Glick Date: Sun, 7 Jan 2024 19:32:58 -0800 Subject: [PATCH 5/8] Apply suggestions from code review Co-authored-by: Steve Piercy --- README.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index ed524620..85a8fed5 100644 --- a/README.rst +++ b/README.rst @@ -98,11 +98,13 @@ Block types index ----------------- plone.volto adds a ``block_types`` index to the Plone catalog. -It can be used to query for items that use a particular type of block:: +It can be used to query for items that use a particular type of block. - portal_catalog.searchResults(block_types="image") +.. code-block:: python -The ``block_types`` index was added in plone.volto 4.1.0. + portal_catalog.searchResults(block_types="image") + +.. versionadded:: 4.1.0 By default it is only added for new Plone sites. To add it to an existing site, run ``plone.volto.upgrades.add_block_types_index`` manually. From 409e5c7919eb98ad6f972cac2d90dd67e9164883 Mon Sep 17 00:00:00 2001 From: David Glick Date: Sun, 7 Jan 2024 19:35:05 -0800 Subject: [PATCH 6/8] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 85a8fed5..b7a17d08 100644 --- a/README.rst +++ b/README.rst @@ -104,7 +104,7 @@ It can be used to query for items that use a particular type of block. portal_catalog.searchResults(block_types="image") -.. versionadded:: 4.1.0 +The ``block_types`` index was added in plone.volto 4.1.0. By default it is only added for new Plone sites. To add it to an existing site, run ``plone.volto.upgrades.add_block_types_index`` manually. From 782630238ae93db5a5f23c714f4dc176a42991e5 Mon Sep 17 00:00:00 2001 From: David Glick Date: Sun, 7 Jan 2024 19:41:33 -0800 Subject: [PATCH 7/8] Update README.rst --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index b7a17d08..e51cfa4d 100644 --- a/README.rst +++ b/README.rst @@ -102,6 +102,8 @@ It can be used to query for items that use a particular type of block. .. code-block:: python + from plone import api + portal_catalog = api.portal.get_tool("portal_catalog") portal_catalog.searchResults(block_types="image") The ``block_types`` index was added in plone.volto 4.1.0. From 71847e3fbea0d57517f42ef13fe00cf62a75c6e8 Mon Sep 17 00:00:00 2001 From: David Glick Date: Mon, 8 Jan 2024 07:57:07 -0800 Subject: [PATCH 8/8] Update news/137.bugfix Co-authored-by: Steve Piercy --- news/137.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/137.bugfix b/news/137.bugfix index a7f5e23e..88b5ed82 100644 --- a/news/137.bugfix +++ b/news/137.bugfix @@ -1 +1 @@ -Avoid accidental acquisition in block_types indexer. @davisagli +Avoid accidental acquisition in ``block_types`` indexer. @davisagli