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

Add missing method in scaling customization #83

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

cekk
Copy link
Member

@cekk cekk commented Aug 17, 2022

In classic Plone the scaling factory breaks without this method

@mister-roboto
Copy link

@cekk thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@cekk cekk requested a review from sneridagh August 17, 2022 07:03
@cekk
Copy link
Member Author

cekk commented Aug 17, 2022

@jenkins-plone-org please run jobs

@tisto
Copy link
Sponsor Member

tisto commented Aug 18, 2022

@cekk do you have a pointer to a bug report or something? I just would like to understand what goes wrong.

@mauritsvanrees
Copy link
Sponsor Member

@cekk do you have a pointer to a bug report or something? I just would like to understand what goes wrong.

The IImageScaleFactory interface requires it.
Both plone.scale and plone.namedfile call it when creating or pre-creating a scale, so it would quickly fail with the old implementation.

Copy link
Sponsor Member

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works.

But I would like to suggest to inherit from DefaultImageScalingFactory instead. The current implementation, especially the __call__ method, is copied from there, and might be missing fixes. If Plone 5.2 still needs to be supported, this might need more care though.

@davisagli
Copy link
Sponsor Member

In fact, this VoltoImageScalingFactory is registered with conditional zcml so that it is only used in Plone 5 (zcml:condition="not-have plone-60")

So, I think an error from the missing method would only happen if you are using Plone 5 with the versions of plone.scale and plone.namedfile that are intended for Plone 6. Is that the case? It would be helpful to see the traceback to make sure we understand the error.

@cekk
Copy link
Member Author

cekk commented Aug 26, 2022

You're right as usually..we were testing new plone.scale and namedfile packages on a plone 52 (i didn't remembered it).
Without them, the error gone.

Here you are the traceback for reference:

2022-08-26 17:33:16,394 ERROR   [Zope.SiteErrorLog:35][waitress-1] AttributeError: http://localhost:7080/Plone/it/folder_listing
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 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 378, 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 95aab2872b4da1409a7c890b8e4437c3, line 1982, in render
  Module 608450dc8ea285d7bfbb3578b83a9ad8, line 860, in render_master
  Module 608450dc8ea285d7bfbb3578b83a9ad8, line 1489, in render_content
  Module 95aab2872b4da1409a7c890b8e4437c3, line 1967, in __fill_content_core
  Module 95aab2872b4da1409a7c890b8e4437c3, line 122, in render_content_core
  Module 95aab2872b4da1409a7c890b8e4437c3, line 493, in render_listing
  Module 95aab2872b4da1409a7c890b8e4437c3, line 903, in render_entries
  Module 95aab2872b4da1409a7c890b8e4437c3, line 1361, in render_listitem
  Module zope.tales.pythonexpr, line 73, in __call__
   - __traceback_info__: (image_scale.tag(item, 'image', scale=thumb_scale_list, css_class=img_class))
  Module <string>, line 1, in <module>
  Module plone.memoize.volatile, line 74, in replacement
  Module plone.namedfile.scaling, line 702, in tag
  Module plone.namedfile.scaling, line 613, in tag
  Module plone.namedfile.scaling, line 538, in scale
  Module plone.scale.storage, line 232, in pre_scale
AttributeError: 'VoltoImageScalingFactory' object has no attribute 'get_original_value
 - Expression: "python:image_scale.tag(item, 'image', scale=thumb_scale_list, css_class=img_class)"
 - Filename:   ... .egg/plone/app/contenttypes/browser/templates/listing.pt
 - Location:   (line 68: col 53)
 - Source:     ... python:image_scale.tag(item, 'image', scale=thumb_scale_list, css_class=img_class) ...
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Expression: "provider:plone.abovecontentbody"
 - Filename:   ... egg/Products/CMFPlone/browser/templates/main_template.pt
 - Location:   (line 94: col 70)
 - Source:     ...
                                     ^
 - Expression: "context/@@main_template/macros/master"
 - Filename:   ... .egg/plone/app/contenttypes/browser/templates/listing.pt
 - Location:   (line 6: col 21)
 - Source:     ... tal:use-macro="context/@@main_template/macros/master"
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  template: <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0x7f0112340f70>
               options: {}
               args: ()
               nothing: None
               modules: <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter object at 0x7f011f2bde80>
               request: <WSGIRequest, URL=http://localhost:7080/Plone/it/folder_listing>
               view: <Products.Five.browser.metaconfigure.SimpleViewClass from /opt/xxx/plone/eggs/plone.app.contenttypes-2.2.3-py3.8.egg/plone/app/contenttypes/browser/templates/listing.pt object at 0x7f01128b0070>
               context: <Container at /Plone/it>
               views: <Products.Five.browser.pagetemplatefile.ViewMapper object at 0x7f0111bd30d0>
               here: <Container at /Plone/it>
               container: <Container at /Plone/it>
               root: <Application at >
               traverse_subpath: []
               user: <SpecialUser 'Anonymous User'>
               default: <DEFAULT>
               repeat: <Products.PageTemplates.engine.RepeatDictWrapper object at 0x7f01194d0b80>
               loop: {'item': <Products.PageTemplates.engine.RepeatItem object at 0x7f00f2f7c670>}
               target_language: None
               translate: <function BaseTemplate.render.<locals>.translate at 0x7f01196d6ca0>
               macroname: 'master'
               attrs: {}
```'

plone.namedfile = 6.0.0b2
plone.scale = 4.0.0b1

@sneridagh
Copy link
Member

What's the status on this one? Can we merge? @cekk how about @mauritsvanrees suggestion?

@cekk
Copy link
Member Author

cekk commented Sep 22, 2022

@sneridagh as i said, my initial problem was that i was testing mixed things (plone52 with experimental packages). I don't know if this could be an use-case but probably can.

Maurits' suggestion is right, but i don't know why the original code was written like this. I can fix it if you want

@mamico
Copy link
Member

mamico commented Dec 29, 2022

@cekk @mauritsvanrees @sneridagh
If I read well, customization was for handle svg (d403c63), but in plone.namedfile 5.6.0 svg are managed by plone.namedfile itself (plone/plone.namedfile#104).

My proposal is to remove the ImageScaleFactory customization in plone.volto and fix namedfile >= 5.6.0 in the package requirements.

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

Successfully merging this pull request may close these issues.

None yet

9 participants