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

plone.session install breaks on ES6 #23

Closed
mauritsvanrees opened this issue Mar 22, 2022 · 1 comment · Fixed by plone/Products.CMFPlone#3470
Closed

plone.session install breaks on ES6 #23

mauritsvanrees opened this issue Mar 22, 2022 · 1 comment · Fixed by plone/Products.CMFPlone#3470
Assignees

Comments

@mauritsvanrees
Copy link
Sponsor Member

I tried coredev 6.0 with the ES6 PLIP. Database was copied from coredev 5.2 on Python 3, and then upgraded. In one Plone site I had all extra modules installed, like placeful workflow and plone.session. When viewing it I got an error while rendering plone.resourceregistries.styles at the top of the page, which resulted in an unstyled page.

Same is true for the standard Plone 5.2 site that I upgraded to Plone 6 ES6. Worked fine at first, but then I activated plone.session:

-03-22 21:52:31,736 INFO    [Products.GenericSetup.tool:1404][waitress-2] Importing profile profile-plone.session:default with dependency strategy upgrade.
2022-03-22 21:52:31,736 INFO    [Products.GenericSetup.tool:1445][waitress-2] Applying main profile profile-plone.session:default
2022-03-22 21:52:31,739 INFO    [GenericSetup.rolemap:100][waitress-2] Role / permission map imported.
2022-03-22 21:52:31,756 INFO    [Products.CMFPlone.resources.browser.combine:104][waitress-2] Wrote combined JS bundle "default".
2022-03-22 21:52:31,757 INFO    [Products.CMFPlone.resources.browser.combine:104][waitress-2] Wrote combined JS bundle "logged-in".
2022-03-22 21:52:31,758 INFO    [Products.CMFPlone.resources.browser.combine:136][waitress-2] Wrote combined CSS bundle "default".
2022-03-22 21:52:31,758 INFO    [Products.CMFPlone.resources.browser.combine:136][waitress-2] Wrote combined CSS bundle "logged-in".
2022-03-22 21:52:31,758 INFO    [Products.CMFPlone.resources.browser.combine:164][waitress-2] Finished bundle compilation.
2022-03-22 21:52:31,785 ERROR   [Products.CMFPlone.resources.browser.resource:136][waitress-3] Bundle 'plone-session-js' has a non existing dependeny on 'plone-logged-in'. Bundle dependency (JS) graceful rewritten to 'plone' Fallback will be removed in Plone 7.
2022-03-22 21:52:31,792 WARNING [Products.CMFPlone.resources.utils:44][waitress-3] Could not find resource acl_users/session/refresh?session_refresh=true&type=css&minutes=5. You may have to create it first.
2022-03-22 21:52:31,792 ERROR   [plone.app.viewletmanager:114][waitress-3] Error while rendering viewlet-manager=plone.htmlhead.links, viewlet=plone.resourceregistries.styles
Traceback (most recent call last):
  File "/Users/maurits/shared-eggs/cp39/plone.app.viewletmanager-3.1.2-py3.9.egg/plone/app/viewletmanager/manager.py", line 110, in render
    html.append(viewlet.render())
  File "/Users/maurits/community/plone-coredev/es6/src/plone.app.layout/plone/app/layout/viewlets/common.py", line 79, in render
    return self.index()
  File "/Users/maurits/community/plone-coredev/es6/src/Products.CMFPlone/Products/CMFPlone/resources/browser/resource.py", line 343, in index
    rendered = self.renderer["css"].render()
  File "/Users/maurits/shared-eggs/cp39/webresource-1.0b8-py3.9.egg/webresource/_api.py", line 619, in render
    return u'\n'.join([
  File "/Users/maurits/shared-eggs/cp39/webresource-1.0b8-py3.9.egg/webresource/_api.py", line 620, in <listcomp>
    res.render(self.base_url) for res in self.resolver.resolve()
  File "/Users/maurits/shared-eggs/cp39/webresource-1.0b8-py3.9.egg/webresource/_api.py", line 380, in render
    'href': self.resource_url(base_url),
  File "/Users/maurits/shared-eggs/cp39/webresource-1.0b8-py3.9.egg/webresource/_api.py", line 182, in resource_url
    parts.append(self.unique_key)
  File "/Users/maurits/shared-eggs/cp39/webresource-1.0b8-py3.9.egg/webresource/_api.py", line 167, in unique_key
    str(uuid.uuid5(namespace_uuid, self.file_hash))
  File "/Users/maurits/shared-eggs/cp39/webresource-1.0b8-py3.9.egg/webresource/_api.py", line 155, in file_hash
    hash_ = base64.b64encode(hash_func(self.file_data).digest()).decode()
TypeError: object supporting the buffer API required
@mauritsvanrees
Copy link
Sponsor Member Author

The error remains after deactivating plone.session. This might be a problem in its uninstall.

@mauritsvanrees mauritsvanrees self-assigned this Mar 29, 2022
mauritsvanrees added a commit to plone/Products.CMFPlone that referenced this issue Mar 29, 2022
…one.session` resources.

Fixes [`plone.session` issue 23](plone/plone.session#23).
Main problem there was that the code could not traverse to the plone.session css resource,
resulting in a resource None, which caused a traceback, resulting in an unstyled site.

After fixing this part, I found another problem:
the `plone.session` css resource had an expression `python: member is not None`, but was still loaded for anonymous users as well.
It turned out that the expression was never checked.
More correctly said: it looks like the expression of the last resource was used for all resources,
even when this expression was empty.
To fix this, I had to pass the expression to the webresource, and move some code from `browser/resource.py` to `webresource.py`.

I added tests with a couple of resource bundles with different expressions.
mister-roboto pushed a commit to plone/buildout.coredev that referenced this issue Mar 30, 2022
Branch: refs/heads/master
Date: 2022-03-30T01:22:10+02:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: plone/Products.CMFPlone@7f4efc3

Fixed evaluating expressions on resources, and especially loading `plone.session` resources.

Fixes [`plone.session` issue 23](plone/plone.session#23).
Main problem there was that the code could not traverse to the plone.session css resource,
resulting in a resource None, which caused a traceback, resulting in an unstyled site.

After fixing this part, I found another problem:
the `plone.session` css resource had an expression `python: member is not None`, but was still loaded for anonymous users as well.
It turned out that the expression was never checked.
More correctly said: it looks like the expression of the last resource was used for all resources,
even when this expression was empty.
To fix this, I had to pass the expression to the webresource, and move some code from `browser/resource.py` to `webresource.py`.

I added tests with a couple of resource bundles with different expressions.

Files changed:
A news/23.bugfix
M Products/CMFPlone/resources/browser/resource.py
M Products/CMFPlone/resources/utils.py
M Products/CMFPlone/resources/webresource.py
M Products/CMFPlone/tests/testResourceRegistries.py
Repository: Products.CMFPlone

Branch: refs/heads/master
Date: 2022-03-30T08:28:04+02:00
Author: Alessandro Pisa (ale-rt) <alessandro.pisa@gmail.com>
Commit: plone/Products.CMFPlone@3a98bcf

Merge pull request #3470 from plone/maurits-fix-plone-session-resources-and-expressions

Fixed plone.session resource, and evaluating expressions on resources

Files changed:
A news/23.bugfix
M Products/CMFPlone/resources/browser/resource.py
M Products/CMFPlone/resources/utils.py
M Products/CMFPlone/resources/webresource.py
M Products/CMFPlone/tests/testResourceRegistries.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant