Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering of RichTextWidget fails if pattern_options contain functions #207

Open
marwoe opened this issue Jun 3, 2024 · 0 comments
Open

Comments

@marwoe
Copy link

marwoe commented Jun 3, 2024

I accidentally came across an error that occurs under certain circumstances when rendering the RichTextWidget. The error occurs under the following conditions: you are using a RichText field with pattern_options that contain a function and there are more than one allowed formats for the field - which is the default (text/html, text/x-web-textile) for new Plone Sites. If you try to edit such a form this leads to the following error:

  Module plone.app.z3cform.widgets.richtext, line 104, in render
  Module plone.app.z3cform.widgets.richtext, line 178, in tinymce_richtextwidget_render
  Module plone.app.z3cform.widgets.richtext, line 146, in render_input_mode
  Module json, line 231, in dumps
  Module json.encoder, line 199, in encode
  Module json.encoder, line 257, in iterencode
  Module json.encoder, line 179, in default
TypeError: Object of type function is not JSON serializable

The problem lies in the render_input_mode method. With only one allowed format the base render method is used, which runs the call_callables method on the pattern_options which resolves the function calls. With multiple allowed formats the call_callables call is missing and the functions (in the patterns) will not be resolved.

This happens with version 4.3.2 and latest Plone version (6.0.11.1, Classic UI) - but as far as i can see this should also happens with every newer version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant