Skip to content

Commit

Permalink
[dev] added patch for slateblockslinkretriever
Browse files Browse the repository at this point in the history
  • Loading branch information
eikichi18 committed Nov 28, 2024
1 parent d640e86 commit 019d24d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
5.6.2 (unreleased)
------------------

- Nothing changed yet.
- Add patch for SlateBlockslinkRetriever.
[eikichi18]


5.6.1 (2024-11-21)
Expand Down
2 changes: 1 addition & 1 deletion src/redturtle/volto/adapters/blocks_linkintegrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 22 additions & 0 deletions src/redturtle/volto/monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
10 changes: 10 additions & 0 deletions src/redturtle/volto/monkey.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
class="plone.volto.transforms.NestedResolveUIDDeserializerBase"
description="Patch for disallow plone.volto deserialization"
/>

<monkey:patch
original="__call__"
replacement=".monkey.plone_volto_serializer_call"
Expand All @@ -56,6 +57,15 @@
description="Fix long request in case pam is not installed"
preserveOriginal="True"
/>

<monkey:patch
original="__call__"
replacement=".monkey.plone_restapi_slateblocklinksretriever_call"
class="plone.restapi.blocks_linkintegrity.SlateBlockLinksRetriever"
description="Fix default of get methon on dict"
preserveOriginal="True"
/>

<monkey:patch
original="search_for_similar"
replacement=".monkey.search_for_similar"
Expand Down

0 comments on commit 019d24d

Please sign in to comment.