Skip to content

Provide IJsonCompatible adapter for RichTextValue objects #1583

@erral

Description

@erral

When defining a default value in a RichText field, this value needs to be passed through a IJsonCompatible adapter, but we are missing the converter for RichTextValue objects, and thus the edit form rendering breaks in Volto.

Dexterity object definition:

    download_full_dataset_text = RichText(
        title=_(
            'Text of the "Download full dataset entry',
        ),
        description=_(
            "Enter the text that will be shown in the Download tab",
        ),
        default=(
            "<p>If you want to download the full dataset, click <a"
            ' href="/en/how-to-guides/how-to-download-spatial-data/how-to-download-m2m">here</a>'
            " to learn more.</p>"
        ),
        required=False,
        readonly=False,
    )

plone.restapi fail when rendering the Volto edit form:

2023-02-13 17:05:44,536 ERROR   [Zope.SiteErrorLog:22][waitress-1] TypeError: http://localhost:3000/en/@types/DataSet
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 371, in publish_module
  Module ZPublisher.WSGIPublisher, line 266, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 63, in call_object
  Module plone.rest.service, line 22, in __call__
  Module plone.restapi.services, line 19, in render
  Module plone.restapi.services.types.get, line 114, in reply
  Module plone.restapi.services.types.get, line 136, in reply_for_type
  Module plone.restapi.types.utils, line 329, in get_info_for_type
  Module plone.restapi.types.utils, line 272, in get_jsonschema_for_portal_type
  Module plone.restapi.types.utils, line 261, in get_jsonschema_for_fti
  Module zope.component.hooks, line 135, in adapter_hook
  Module plone.restapi.serializer.converters, line 136, in dict_converter
  Module plone.restapi.serializer.converters, line 68, in json_compatible
  Module zope.component.hooks, line 135, in adapter_hook
  Module plone.restapi.serializer.converters, line 136, in dict_converter
  Module plone.restapi.serializer.converters, line 68, in json_compatible
  Module zope.component.hooks, line 135, in adapter_hook
  Module plone.restapi.serializer.converters, line 80, in default_converter
TypeError: No converter for making RichTextValue object. (Did you mean <attribute>.raw or <attribute>.output?) (<class 'plone.app.textfield.value.RichTextValue'>) JSON compatible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions