plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
245 stars 188 forks source link

TTW theming is broken (`AttributeError: __call__` on resources) #3705

Open laulaz opened 1 year ago

laulaz commented 1 year ago

BUG REPORT

What I did:

I uploaded a theme through the Theming control panel. You can reproduce with this theme for example (it is barceloneta with another name for testing) : barcelonetattw.zip

This is the same issue as #3613.

What actually happened:

Website is broken, because of an error in plone.resourceregistries.styles viewlet manager, when trying to render ++theme++barcelonetattw/css/barceloneta.css :

2022-12-20 10:31:03,235 ERROR   [plone.app.viewletmanager:114][MainThread] Error while rendering viewlet-manager=plone.htmlhead.links, viewlet=plone.resourceregistries.styles
Traceback (most recent call last):
  File "/Users/laurent/.buildout/eggs/plone.app.viewletmanager-4.0.0-py3.8.egg/plone/app/viewletmanager/manager.py", line 110, in render
    html.append(viewlet.render())
  File "/Users/laurent/.buildout/eggs/plone.app.layout-4.0.0-py3.8.egg/plone/app/layout/viewlets/common.py", line 70, in render
    return self.index()
  File "/Users/laurent/.buildout/eggs/Products.CMFPlone-6.0.0-py3.8.egg/Products/CMFPlone/resources/browser/resource.py", line 311, in index
    rendered = self.renderer["css"].render()
  File "/Users/laurent/.buildout/eggs/webresource-1.1-py3.8.egg/webresource/_api.py", line 703, in render
    return u'\n'.join([
  File "/Users/laurent/.buildout/eggs/webresource-1.1-py3.8.egg/webresource/_api.py", line 704, in <listcomp>
    res.render(self.base_url) for res in self.resolver.resolve()
  File "/Users/laurent/.buildout/eggs/webresource-1.1-py3.8.egg/webresource/_api.py", line 373, in render
    'href': self.resource_url(base_url),
  File "/Users/laurent/.buildout/eggs/webresource-1.1-py3.8.egg/webresource/_api.py", line 212, in resource_url
    parts.append(self.unique_key)
  File "/Users/laurent/.buildout/eggs/webresource-1.1-py3.8.egg/webresource/_api.py", line 197, in unique_key
    str(uuid.uuid5(namespace_uuid, self.file_hash))
  File "/Users/laurent/.buildout/eggs/webresource-1.1-py3.8.egg/webresource/_api.py", line 184, in file_hash
    hash_ = base64.b64encode(hash_func(self.file_data).digest())
  File "/Users/laurent/.buildout/eggs/Products.CMFPlone-6.0.0-py3.8.egg/Products/CMFPlone/resources/webresource.py", line 24, in file_data
    data = get_resource(self.context, self.resource)
  File "/Users/laurent/.buildout/eggs/Products.CMFPlone-6.0.0-py3.8.egg/Products/CMFPlone/resources/utils.py", line 74, in get_resource
    result = resource()
AttributeError: __call__
screenshot

Ugly quickfix:

For the record, we did an ugly quickfix in our POC project to make it "work", replacing the line https://github.com/plone/Products.CMFPlone/blob/7e074afbade044b56dd1aad163dd14194ced46e1/Products/CMFPlone/resources/utils.py#L74 by :

try:
    result = resource()
except:
    if isinstance(resource.data, bytes):
        result = resource.data
    elif isinstance(resource.data.data, bytes):
        result = resource.data.data

What version of Plone/ Addons I am using:

Plone 6.0.0 final

josephnoir commented 1 month ago

I have the same issue. But since I'm using the docker image I can't easily make persistent changes to the files. Are there plans to fix this?

What version of Plone/ Addons I am using: