From 8f41425efdbe9f0bcb260547f5f12f0c138d0bc7 Mon Sep 17 00:00:00 2001 From: ale-rt Date: Wed, 13 Dec 2023 20:57:55 +0100 Subject: [PATCH] [fc] Repository: plone.app.theming Branch: refs/heads/master Date: 2023-12-13T20:57:55+01:00 Author: Maurits van Rees (mauritsvanrees) Commit: https://github.com/plone/plone.app.theming/commit/342cbb9ed967132855518bb6d8225785d76abeb5 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: A news/230.bugfix M src/plone/app/theming/browser/custom_css.py M src/plone/app/theming/tests/test_controlpanel.py --- last_commit.txt | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/last_commit.txt b/last_commit.txt index dea3f4e053..4d9633c89c 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -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) -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) +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'