-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
deserializer = queryMultiAdapter( (field, fake_context, self.request), IFieldDeserializer ) - It does correctly trigger it, but
iter_block_transform_handlers
doesn't return the handlers correctly in the subscribers request inplone.restapi/src/plone/restapi/blocks.py
Lines 42 to 57 in 259d969
def iter_block_transform_handlers(context, block_value, interface): """Find valid handlers for a particular block transformation. Looks for adapters of the context and request to this interface. Then skips any that are disabled or don't match the block type, and returns the remaining handlers sorted by `order`. """ block_type = block_value.get("@type", "") handlers = [] for handler in subscribers((context, getRequest()), interface): if handler.block_type == block_type or handler.block_type is None: handler.blockid = id handlers.append(handler) for handler in sorted(handlers, key=lambda h: h.order): if not getattr(handler, "disabled", False): yield handler - 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
Metadata
Metadata
Assignees
Labels
No labels