Block transforms don't run for control panels
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 109
- Forks
- 107
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 4
Description
There doesn't seem to be an adapter for control panels, so if you try to use blocks in a control panel, the block transforms will never run, meaning we lose out on functionality like create a resolveuid link for links.
Steps to reproduce
- Create a control panel with the ability to add/ edit blocks in it (e.g. enable https://github.com/pretagov/volto-slots-editor)
- Create a text block with a link in it
- Save the control panel
- View the data stored from the control panel
Expected result
The URL of the link has been changed to resolveuid
Actual result
The URL stays as the absolute URL created from the POST request.
Investigation
- https://github.com/plone/plone.restapi/blob/259d9691d6f0024ae717017f8f48f0ce5229d1e0/src/plone/restapi/deserializer/controlpanels/__init__.py#L55-L57 should trigger the Blocks field deserialization handler
- It does correctly trigger it, but
iter_block_transform_handlersdoesn't return the handlers correctly in the subscribers request in https://github.com/plone/plone.restapi/blob/259d9691d6f0024ae717017f8f48f0ce5229d1e0/src/plone/restapi/blocks.py#L42-L57 - Looks like the FakeDXContext doesn't get the subscriptions correctly. If I put a debugger in the subscription code above and swap the context passed in (i.e. the
FakeDXContext) for a real object (e.g. withplone.api.portal.get()or an unrestrictedTraverse to a page) the subscribers are correctly found and triggered
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/plone/restapi/deserializer/controlpanels/init.py and src/plone/restapi/blocks.py, then trace how FakeDXContext is passed to iter_block_transform_handlers and how subscriptions are resolved. Compare this with a real object context as described in the investigation. Done means block transforms run for control-panel data and links are stored using resolveuid URLs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100