Skip to content

Commit

Permalink
[fc] Repository: plone.app.theming
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2023-12-13T20:57:55+01:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: plone/plone.app.theming@342cbb9

Fix AttributeError in custom.css: "module 'wsgiref' has no attribute 'handlers'". (#231)

This problem is usually hidden if `plone.app.caching` is available.
Fixes plone/plone.app.theming#230

And this PR adds the first test for `custom.css`, which indeed shows this problem.
This fixes plone/plone.app.theming#190

Files changed:
A news/230.bugfix
M src/plone/app/theming/browser/custom_css.py
M src/plone/app/theming/tests/test_controlpanel.py
  • Loading branch information
ale-rt committed Dec 13, 2023
1 parent 2fa981d commit 8f41425
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
Repository: plone.restapi
Repository: plone.app.theming


Branch: refs/heads/main
Date: 2023-12-13T12:03:09+01:00
Author: Timo Stollenwerk (tisto) <[email protected]>
Commit: https://github.com/plone/plone.restapi/commit/260066b4dc98059ef9bcd86dfa8428f60a4e9347
Branch: refs/heads/master
Date: 2023-12-13T20:57:55+01:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/plone.app.theming/commit/342cbb9ed967132855518bb6d8225785d76abeb5

Update changelog
Fix AttributeError in custom.css: "module 'wsgiref' has no attribute 'handlers'". (#231)

This problem is usually hidden if `plone.app.caching` is available.
Fixes https://github.com/plone/plone.app.theming/issues/230

And this PR adds the first test for `custom.css`, which indeed shows this problem.
This fixes https://github.com/plone/plone.app.theming/issues/190

Files changed:
M news/1737.bugfix
A news/230.bugfix
M src/plone/app/theming/browser/custom_css.py
M src/plone/app/theming/tests/test_controlpanel.py

b'diff --git a/news/1737.bugfix b/news/1737.bugfix\nindex a4953486a..7b377ae93 100644\n--- a/news/1737.bugfix\n+++ b/news/1737.bugfix\n@@ -1,2 +1 @@\n-Remove wrong `preview_image_link` addition from blocks (de)serializers\n-[sneridagh]\n+Remove wrong `preview_image_link` addition from blocks (de)serializers. @sneridagh\n'
b'diff --git a/news/230.bugfix b/news/230.bugfix\nnew file mode 100644\nindex 00000000..05ffb7c6\n--- /dev/null\n+++ b/news/230.bugfix\n@@ -0,0 +1,2 @@\n+Fix AttributeError in ``custom.css``: "module \'wsgiref\' has no attribute \'handlers\'".\n+[maurits]\ndiff --git a/src/plone/app/theming/browser/custom_css.py b/src/plone/app/theming/browser/custom_css.py\nindex 135da816..bf252db3 100644\n--- a/src/plone/app/theming/browser/custom_css.py\n+++ b/src/plone/app/theming/browser/custom_css.py\n@@ -1,11 +1,11 @@\n from plone.app.theming.interfaces import IThemeSettings\n from plone.registry.interfaces import IRegistry\n from Products.Five.browser import BrowserView\n+from wsgiref.handlers import format_date_time\n from zope.component import getUtility\n \n import dateutil\n import time\n-import wsgiref\n \n \n class CustomCSSView(BrowserView):\n@@ -27,6 +27,6 @@ def __call__(self):\n # Format a Python datetime object as an RFC1123 date.\n self.request.response.setHeader(\n "Last-Modified",\n- wsgiref.handlers.format_date_time(time.mktime(dt.timetuple())),\n+ format_date_time(time.mktime(dt.timetuple())),\n )\n return theme_settings.custom_css\ndiff --git a/src/plone/app/theming/tests/test_controlpanel.py b/src/plone/app/theming/tests/test_controlpanel.py\nindex c56ab854..327ca6c7 100644\n--- a/src/plone/app/theming/tests/test_controlpanel.py\n+++ b/src/plone/app/theming/tests/test_controlpanel.py\n@@ -86,3 +86,27 @@ def test_upload_theme_file_withdata(self):\n \'{"failure": "error"}\', # TODO: Should be {\'success\':\'create\'}\n str(self.browser.contents),\n )\n+\n+ def test_custom_css(self):\n+ # By default custom.css is empty.\n+ self.browser.handleErrors = False\n+ self.browser.open("custom.css")\n+ self.assertEqual(self.browser.contents, "")\n+ self.assertEqual(\n+ self.browser.headers["Content-Type"],\n+ "text/css; charset=utf-8",\n+ )\n+\n+ # Go to the control panel and add custom css.\n+ self.goto_controlpanel()\n+ css = "body {background-color: blue;}"\n+ self.browser.getControl(name="custom_css").value = css\n+ self.browser.getControl(name="form.button.AdvancedSave").click()\n+\n+ # Check that the css is available.\n+ self.browser.open("custom.css")\n+ self.assertEqual(self.browser.contents, css)\n+ self.assertEqual(\n+ self.browser.headers["Content-Type"],\n+ "text/css; charset=utf-8",\n+ )\n'

0 comments on commit 8f41425

Please sign in to comment.