From 019d24d9c6227f0ce544a37440a4866f0e10d712 Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Thu, 28 Nov 2024 13:24:29 +0100 Subject: [PATCH] [dev] added patch for slateblockslinkretriever --- CHANGES.rst | 3 ++- .../volto/adapters/blocks_linkintegrity.py | 2 +- src/redturtle/volto/monkey.py | 22 +++++++++++++++++++ src/redturtle/volto/monkey.zcml | 10 +++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index beda951..0e55117 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,8 @@ Changelog 5.6.2 (unreleased) ------------------ -- Nothing changed yet. +- Add patch for SlateBlockslinkRetriever. + [eikichi18] 5.6.1 (2024-11-21) diff --git a/src/redturtle/volto/adapters/blocks_linkintegrity.py b/src/redturtle/volto/adapters/blocks_linkintegrity.py index 3eee76c..c4ee9f3 100644 --- a/src/redturtle/volto/adapters/blocks_linkintegrity.py +++ b/src/redturtle/volto/adapters/blocks_linkintegrity.py @@ -40,7 +40,7 @@ class SubBlocksRetriever(SlateBlockLinksRetriever): def extract_links(self, block_data): children = iterate_children(block_data or []) for child in children: - node_type = child.get("type") + node_type = child.get("type", "") if node_type: handler = getattr(self, f"handle_{node_type}", None) if handler: diff --git a/src/redturtle/volto/monkey.py b/src/redturtle/volto/monkey.py index 180888e..6b1d663 100644 --- a/src/redturtle/volto/monkey.py +++ b/src/redturtle/volto/monkey.py @@ -8,6 +8,7 @@ from plone.event.interfaces import IEventAccessor from plone.event.interfaces import IRecurrenceSupport from plone.event.recurrence import recurrence_sequence_ical +from plone.restapi.deserializer.blocks import iterate_children # from plone.event.utils import pydt from Products.CMFPlone.interfaces import IConstrainTypes @@ -193,3 +194,24 @@ def search_for_similar(*args, **kwargs): return original_obj._old_search_for_similar() return [] + + +def plone_restapi_slateblocklinksretriever_call(self, block): + """ + plone.restapi.blocks_linkintegrity.SlateBlockLinksRetriever.__call__ patch + Add default to get at line 208 + """ + + value = (block or {}).get(self.field, []) + children = iterate_children(value or []) + + for child in children: + node_type = child.get("type", "") + if node_type: + handler = getattr(self, f"handle_{node_type}", None) + if handler: + value = handler(child) + if value: + self.links.append(value) + + return self.links diff --git a/src/redturtle/volto/monkey.zcml b/src/redturtle/volto/monkey.zcml index fc06d6d..763ed32 100644 --- a/src/redturtle/volto/monkey.zcml +++ b/src/redturtle/volto/monkey.zcml @@ -34,6 +34,7 @@ class="plone.volto.transforms.NestedResolveUIDDeserializerBase" description="Patch for disallow plone.volto deserialization" /> + + + +