plone / Products.CMFPlone

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

plone-compile-resources (_generate_gruntfile.py) fails on (any) resourceDirectory using browser layer #2080

Closed seanupton closed 7 years ago

seanupton commented 7 years ago

_generate_gruntfile.py uses Traversable.unrestrictedTraverse() to introspect resources provided by browser resources and/or resource directories. This fails for any resourceDirectory where plone.browserlayer layer specification is used, which pits core resource compilation process against a stated best-practice for add-on developers. This is even the case when the bundle being compiled is completely unrelated to the add-on in question.

This should never happen. This failure can be fixed by having the script load all declared layers.

Reproducing:

In Products.CMFPlone master (~5.1b4.dev0), add any add-on with:

  1. a browser:resourceDirectory declaration in ZCML, with a layer parameter to specify a browser layer interface (plone.browserlayer);
  2. registry.xml entries for resources and/or bundles using those resources;
  3. Run ./bin/plone-compile-resources for your instance.

Desired outcome:

Successful build, no errors.

What actually happened:

TraversalError attempting to traverse to the namespace/name in question, because lookup using acquired request fails when layers are not marked on the request.

What version of Plone/ Addons I am using:

Products.CMFPlone master (~5.1b4.dev0).

Fixing:

Layers should be loaded by script; there is an available request object to mark. This is trivially implemented by getting registrations from the site's components, and marking the request with all interfaces.

hvelarde commented 7 years ago

@keul is this related with the problem you described some months ago? I can't remember.

hvelarde commented 7 years ago

I just saw @seanupton comment on #1749

seanupton commented 7 years ago

@hvelarde @keul I suspect that these are distinct, unless there is some kind of subprocess thing happening in the TTW build of resources (I do not understand that process well enough), but this issue and its fix in PR is for cases where there is no real HTTPRequest, like in the case of the build scripts.