plone / plone.app.textfield

provides a zope.schema style field type called RichText which can be used to store a value with a related MIME type
2 stars 7 forks source link

Traceback after inserting image #46

Open Rudd-O opened 2 years ago

Rudd-O commented 2 years ago

if I edit an article and I upload/embed that image, I get the following traceback:

We’re sorry, but there seems to be an error…

Here is the full error message:

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 167, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 376, in publish_module
  Module ZPublisher.WSGIPublisher, line 271, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module zope.browserpage.simpleviewclass, line 41, in __call__
  Module Products.Five.browser.pagetemplatefile, line 126, in __call__
  Module Products.Five.browser.pagetemplatefile, line 58, in __call__
  Module zope.pagetemplate.pagetemplate, line 133, in pt_render
  Module Products.PageTemplates.engine, line 365, in __call__
  Module z3c.pt.pagetemplate, line 176, in render
  Module chameleon.zpt.template, line 302, in render
  Module chameleon.template, line 215, in render
  Module chameleon.utils, line 53, in raise_with_traceback
  Module chameleon.template, line 192, in render
  Module afb8202ab5c60243af6dce9f452ceb61, line 296, in render
  Module fd330b5359a3c56cc52bb2a8306bb5da, line 921, in render_master
  Module fd330b5359a3c56cc52bb2a8306bb5da, line 1544, in render_content
  Module afb8202ab5c60243af6dce9f452ceb61, line 281, in __fill_content_core
  Module afb8202ab5c60243af6dce9f452ceb61, line 166, in render_content_core
  Module zope.tales.pythonexpr, line 73, in __call__
   - __traceback_info__: (context.text.output_relative_to(view.context))
  Module <string>, line 1, in <module>
  Module plone.app.textfield.value, line 122, in output_relative_to
  Module plone.app.textfield.transform, line 92, in __call__
plone.app.textfield.interfaces.TransformError: plone.app.textfield.interfaces.TransformError: Error during transformation

 - Expression: "python:context.text.output_relative_to(view.context)"
 - Filename:   ... egg/plone/app/contenttypes/browser/templates/newsitem.pt
 - Location:   (line 15: col 96)
 - Source:     ... ure python:context.text.output_relative_to(view.context)" ta ...
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Expression: "provider:plone.abovecontentbody"
 - Filename:   ... egg/Products/CMFPlone/browser/templates/main_template.pt
 - Location:   (line 107: col 74)
 - Source:     ... ontent="structure provider:plone.abovecontentbody" />
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Expression: "context/@@main_template/macros/master"
 - Filename:   ... egg/plone/app/contenttypes/browser/templates/newsitem.pt
 - Location:   (line 6: col 21)
 - Source:     ... tal:use-macro="context/@@main_template/macros/master"
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  template: <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0x7637ea283b20>
               options: {}
               args: ()
               nothing: None
               modules: <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter object at 0x7637f103d0f0>
               request: <WSGIRequest, URL=http://rudd-x.com/zope/master/Rudd-O.com/en/linux-and-free-software/kde-4.2-nepomuk-and-linux-distributions/newsitem_view>
               view: <Products.Five.browser.metaconfigure.SimpleViewClass from /home/user/Projects/Rudd-O.com/localserver/buildout-cache/eggs/cp310/plone.app.contenttypes-3.0.0b1-py3.10.egg/plone/app/contenttypes/browser/templates/newsitem.pt object at 0x7637e919b8b0>
               context: <FolderishNewsItem at /Rudd-O.com/en/linux-and-free-software/kde-4.2-nepomuk-and-linux-distributions>
               views: <Products.Five.browser.pagetemplatefile.ViewMapper object at 0x7637e919bfa0>
               here: <FolderishNewsItem at /Rudd-O.com/en/linux-and-free-software/kde-4.2-nepomuk-and-linux-distributions>
               container: <FolderishNewsItem at /Rudd-O.com/en/linux-and-free-software/kde-4.2-nepomuk-and-linux-distributions>
               root: <Application at >
               traverse_subpath: []
               user: <PropertiedUser 'admin'>
               default: <DEFAULT>
               repeat: <Products.PageTemplates.engine.RepeatDictWrapper object at 0x7637e917db40>
               loop: {}
               target_language: 'en'
               translate: <function BaseTemplate.render.<locals>.translate at 0x7637e91668c0>
               macroname: 'master'
               attrs: {}

Deleting the embedded image (TinyMCE edit is not affected) from the article content makes the traceback go away.

I am using Plone 6 beta.

Rudd-O commented 2 years ago

I suspect this is related to the imagetransforms changes that have been going on lately.

Rudd-O commented 2 years ago
2022-09-08 00:53:28,984 ERROR   [plone.app.textfield:91][waitress-0] Transform exception
Traceback (most recent call last):
  File "/home/user/Projects/Rudd-O.com/localserver/buildout-cache/eggs/cp310/plone.app.textfield-1.3.6-py3.10.egg/plone/app/textfield/transform.py", line 57, in __call__
    data = transforms.convertTo(
  File "/home/user/Projects/Rudd-O.com/localserver/buildout-cache/eggs/cp310/Products.PortalTransforms-3.2.0-py3.10.egg/Products/PortalTransforms/TransformEngine.py", line 172, in convertTo
    result = transform.convert(orig, data, context=context,
  File "/home/user/Projects/Rudd-O.com/localserver/buildout-cache/eggs/cp310/Products.PortalTransforms-3.2.0-py3.10.egg/Products/PortalTransforms/chain.py", line 49, in convert
    data = transform.convert(orig, data, **kwargs)
  File "/home/user/Projects/Rudd-O.com/localserver/buildout-cache/eggs/cp310/Products.PortalTransforms-3.2.0-py3.10.egg/Products/PortalTransforms/Transform.py", line 202, in convert
    return self._v_transform.convert(*args, **kwargs)
  File "/home/user/Projects/Rudd-O.com/localserver/buildout-cache/eggs/cp310/plone.outputfilters-5.0.0b1-py3.10.egg/plone/outputfilters/transforms/html_to_plone_outputfilters_html.py", line 33, in convert
    res = apply_filters(filters, orig)
  File "/home/user/Projects/Rudd-O.com/localserver/buildout-cache/eggs/cp310/plone.outputfilters-5.0.0b1-py3.10.egg/plone/outputfilters/__init__.py", line 7, in apply_filters
    res = filter(data)
  File "/home/user/Projects/Rudd-O.com/localserver/buildout-cache/eggs/cp310/plone.outputfilters-5.0.0b1-py3.10.egg/plone/outputfilters/filters/picture_variants.py", line 50, in __call__
    elem.replace_with(self.img2picturetag.create_picture_tag(sourceset, elem.attrs))
  File "/home/user/Projects/Rudd-O.com/localserver/buildout-cache/eggs/cp310/plone.namedfile-6.0.0b3-py3.10.egg/plone/namedfile/picture.py", line 93, in create_picture_tag
    scale_width = self.get_scale_width(scale)
  File "/home/user/Projects/Rudd-O.com/localserver/buildout-cache/eggs/cp310/plone.namedfile-6.0.0b3-py3.10.egg/plone/namedfile/picture.py", line 50, in get_scale_width
    return scale_info[0]
TypeError: 'NoneType' object is not subscriptable

I wasn't very much wrong about it!

Rudd-O commented 2 years ago

OK. I think it has to do with my policy product overriding the allowed_sizes image scales, which are not kept in sync with TinyMCE. Let me go back to default and see.

Rudd-O commented 2 years ago

I went back to default and the error persists.

EDIT, no I was missing some scales. Fixed that, boom, site works.

Rudd-O commented 2 years ago

Yep, this image scales thing needs to be documented as a breaking change that policy product creators must revise.