plone / Products.CMFPlone

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

resource registries: Developing a bundle without resources seems to break the registry #2506

Closed fredvd closed 1 year ago

fredvd commented 6 years ago

What I did:

Testing Plone.app.mosaic with Plone 5.1 coredev testing branch by using https://github.com/plone/plone.app.mosaic/blob/master/test-5.1.coredev.cfg .

Install Plone site, install Mosaic add'on. Go to resource registries in the control panel Activate development mode Develop Javascript for either mosaic Grid or Mosaic styles

What I expect to happen:

One or more javascripts that switch to development mode.

What actually happened:

I get a traceback that the plone.resourceregistries.scripts viewlet can no longer be rendered as there are no resources to add:

2018-09-03 17:34:16 ERROR plone.app.viewletmanager Error while rendering viewlet-manager=plone.scripts, viewlet=plone.resourceregistries.scripts
Traceback (most recent call last):
  File "/Users/fred/.buildout/eggs/plone.app.viewletmanager-2.0.12-py2.7.egg/plone/app/viewletmanager/manager.py", line 106, in render
    html.append(viewlet.render())
  File "/Users/fred/buildouts/plone.app.mosaic/extras/plone.app.layout/plone/app/layout/viewlets/common.py", line 59, in render
    return self.index()
  File "/Users/fred/.buildout/eggs/Zope2-2.13.27-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 125, in __call__
    return self.im_func(im_self, *args, **kw)
  File "/Users/fred/.buildout/eggs/Zope2-2.13.27-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 59, in __call__
    sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
  File "/Users/fred/.buildout/eggs/zope.pagetemplate-4.2.1-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 137, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations
  File "/Users/fred/.buildout/eggs/five.pt-2.2.5-py2.7.egg/five/pt/engine.py", line 98, in __call__
    return self.template.render(**kwargs)
  File "/Users/fred/.buildout/eggs/z3c.pt-3.0.0a1-py2.7.egg/z3c/pt/pagetemplate.py", line 163, in render
    return base_renderer(**context)
  File "/Users/fred/.buildout/eggs/Chameleon-2.25-py2.7.egg/chameleon/zpt/template.py", line 261, in render
    return super(PageTemplate, self).render(**vars)
  File "/Users/fred/.buildout/eggs/Chameleon-2.25-py2.7.egg/chameleon/template.py", line 191, in render
    raise_with_traceback(exc, tb)
  File "/Users/fred/.buildout/eggs/Chameleon-2.25-py2.7.egg/chameleon/template.py", line 171, in render
    self._render(stream, econtext, rcontext)
  File "dedc98af4db052812839bd71800de926.py", line 151, in render
  File "/Users/fred/.buildout/eggs/five.pt-2.2.5-py2.7.egg/five/pt/expressions.py", line 161, in __call__
    return base()
  File "/Users/fred/buildouts/plone.app.mosaic/extras/Products.CMFPlone/Products/CMFPlone/resources/browser/scripts.py", line 150, in scripts
    result.extend(self.ordered_bundles_result())
  File "/Users/fred/buildouts/plone.app.mosaic/extras/Products.CMFPlone/Products/CMFPlone/resources/browser/resource.py", line 204, in ordered_bundles_result
    self.get_data(bundle, result)
  File "/Users/fred/buildouts/plone.app.mosaic/extras/Products.CMFPlone/Products/CMFPlone/resources/browser/scripts.py", line 52, in get_data
    conditionalcomment=bundle.conditionalcomment,
  File "/Users/fred/buildouts/plone.app.mosaic/extras/Products.CMFPlone/Products/CMFPlone/resources/browser/scripts.py", line 23, in _add_resources
    for resource in resources_to_add:
TypeError: 'NoneType' object is not iterable

 - Expression: "view/scripts"
 - Filename:   ... .CMFPlone/Products/CMFPlone/resources/browser/scripts.pt
 - Location:   (line 2: col 28)
 - Source:     ... :scripts repeat="script view/scripts"><tal:block define="con ...
                                           ^^^^^^^^^^^^
 - Arguments:  repeat: {...} (0)
               template: <ViewPageTemplateFile - at 0x10facfc10>
               views: <ViewMapper - at 0x110a38510>
               modules: <instance - at 0x1092b23b0>
               args: <tuple - at 0x1082c5050>
               here: <ImplicitAcquisitionWrapper Plone at 0x10ed67b90>
               user: <ImplicitAcquisitionWrapper - at 0x1109ef1e0>
               nothing: <NoneType - at 0x108235f28>
               container: <ImplicitAcquisitionWrapper Plone at 0x10ed67b90>
               request: <instance - at 0x10beb2cb0>
               wrapped_repeat: <SafeMapping - at 0x110a4c418>
               traverse_subpath: <list - at 0x10be80200>
               default: <object - at 0x10831bae0>
               loop: {...} (0)
               context: <ImplicitAcquisitionWrapper Plone at 0x10ed67b90>
               view: <SimpleViewletClass from /Users/fred/buildouts/plone.app.mosaic/extras/Products.CMFPlone/Products/CMFPlone/resources/browser/scripts.pt plone.resourceregistries.scripts at 0x110a38650>
               translate: <function translate at 0x1118977d0>
               root: <ImplicitAcquisitionWrapper Zope at 0x10fc54a00>
               options: {...} (0)
               target_language: <NoneType - at 0x108235f28>

The only way to back out of this is to revert the last trancaction in the undo tab in the ZMI. Upon closer inspection and a lot of trial and error debugging it is only the mosaic-styles and mosaic-grids bundles that cause the registry to break. Checking their registration in plone.app.mosaic show that these bundles have no resources compared to the other plone.app.mosaic resources.

  <records prefix="plone.bundles/mosaic-grid"
           interface='Products.CMFPlone.interfaces.IBundleRegistry'>
    <value key="jscompilation">++plone++mosaic/mosaic-grid.js</value>
    <value key="csscompilation">++plone++mosaic/mosaic-grid.css</value>
    <value key="last_compilation">2017-04-05 00:00:00</value>
    <value key="compile">False</value>
    <value key="merge_with">default</value>
    <value key="enabled">True</value>
  </records>

  <records prefix="plone.bundles/mosaic-styles"
           interface='Products.CMFPlone.interfaces.IBundleRegistry'>
    <value key="jscompilation">++plone++mosaic/mosaic-styles.js</value>
    <value key="csscompilation">++plone++mosaic/mosaic-styles.css</value>
    <value key="last_compilation">2017-04-05 00:00:00</value>
    <value key="compile">False</value>
    <value key="merge_with">default</value>
    <value key="enabled">True</value>
  </records>

What version of Plone/ Addons I am using:

https://github.com/plone/plone.app.mosaic/blob/master/test-5.1.coredev.cfg

djowett commented 5 years ago

Wow - thanks Fred - you saved me a load of frustration here! (Plone 5.1.4)

jensens commented 1 year ago

I close the issue, because it addresses a Plone version that is no longer supported. If you think this is wrong please reopen the issue and assign a matching milestone.