Uploading a theme breaks the website

Hello,

I'm trying to create a theme for our Plone 6 (Classic, using Docker) based on the barceloneta theme. I tried to follow the guide in the docs and the one on the Plone training website.

Once I rebuild the theme (npm run build), upload the zip, and activate it the website breaks. I added the error below. The same happens it I simply export the default theme and upload it again.

Is this a known issue, are there workarounds, or should I follow different instructions?

Kind regards
Raphael

  Module Products.CMFPlone.resources.webresource, line 22, in file_data
  Module Products.CMFPlone.resources.utils, line 74, in get_resource
AttributeError: __call__

 - Expression: "provider:plone.scripts"
 - Filename:   ... ges/Products/CMFPlone/browser/templates/main_template.pt
 - Location:   (line 38: col 32)
 - Source:     ... al:replace="structure provider:plone.scripts" />
                                         ^^^^^^^^^^^^^^^^^^^^^^
 - Expression: "context/main_template/macros/master"
 - Filename:   ... /site-packages/plone/app/portlets/dashboard/dashboard.pt
 - Location:   (line 6: col 23)
 - Source:     ... etal:use-macro="context/main_template/macros/master"
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  template: <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0x7dcdf060a010>
               options: {}
               args: ()
               nothing: None
               modules: <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter object at 0x7dcdf52f0710>
               request: <WSGIRequest, URL=http://localhost:8080/inet3/dashboard>
               view: <Products.Five.browser.metaconfigure.SimpleViewClass from /app/lib/python3.11/site-packages/plone/app/portlets/dashboard/dashboard.pt object at 0x7dcdee87a210>
               context: <PloneSite at /inet3>
               views: <Products.Five.browser.pagetemplatefile.ViewMapper object at 0x7dcdec3a3310>
               here: <PloneSite at /inet3>
               container: <PloneSite at /inet3>
               root: <Application at >
               traverse_subpath: []
               user: <PropertiedUser 'admin'>
               default: <DEFAULT>
               repeat: <Products.PageTemplates.engine.RepeatDictWrapper object at 0x7dcdeef21810>
               loop: {}
               target_language: None
               translate: <function BaseTemplate.render.<locals>.translate at 0x7dcdec384cc0>
               macroname: 'master'
               attrs: {}

Probably a bug and best you report it at Sign in to GitHub · GitHub
Thanks!

What about the control panel -> resource registries? It should use the standard theme and maybe you can fix your theme there.

This happens as well if I export the default theme and import it again. And once its broken, the site gets basically impossible to navigate.

If I go to @@resourceregistry-controlpanel directly, I only says

error while rendering plone.resourceregistries.styles

at the top and the rest of the site is broken, showing the same error I posted above.

It looks like this bug that was already reported nearly two years ago: TTW theming is broken (`AttributeError: __call__` on resources) · Issue #3705 · plone/Products.CMFPlone · GitHub

1 Like

from the issue, seems that import load the file as a zope file and not as a resource, so the missing method. Try to go to ZMI -> portal_resources and see if there's something there. If the resource is there, that's what is happening. The fix is quite ugly but being it an exception and being it on public files, shouldn't too bad implementing it. A real fix should be done in the theme import.

looking at the code

maybe just improving the first condition

if hasattr(aq_base(resource), "GET")

can solve the problem. You can drop a shell in the docker container via commands and put a breakpoint before that line to see what happen after the zip upload of the theme.

Or in

We could add the ++theme++ but this is just a guess.

In plone we have:

  • filesystem files
  • resources files (those in ZMI)
  • callable resource

Those were some helpful hints. We mounted the file into docker ourselves and changed line 67 to alternatively check if the path starts with "++theme++".

It's this part.

And ours now reads:

if isinstance(resource, FilesystemFile) or path.startswith("++theme++"):

Now the website loads again. But I am not sure what the implications are.

Can we modify the resource in Plone itself to have the correct type instead of implementing this check here?