From b56411eaa2b5f633ad046c6ef5f3fdb27e9288a3 Mon Sep 17 00:00:00 2001 From: gforcada Date: Sun, 13 Oct 2024 00:09:54 +0200 Subject: [PATCH] [fc] Repository: plone.indexer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Branch: refs/heads/master Date: 2024-10-07T21:24:17Z Author: pre-commit-ci[bot] (pre-commit-ci[bot]) <66853113+pre-commit-ci[bot]@users.noreply.github.com> Commit: https://github.com/plone/plone.indexer/commit/161c2f239dfb12f73dbd4567ff6577c2ae5f6076 [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 24.8.0 → 24.10.0](https://github.com/psf/black/compare/24.8.0...24.10.0) Files changed: M .pre-commit-config.yaml Repository: plone.indexer Branch: refs/heads/master Date: 2024-10-13T00:09:54+02:00 Author: Gil Forcada Codinachs (gforcada) Commit: https://github.com/plone/plone.indexer/commit/1cc8ef81f83ea9361ca1d767e69a166e9edeb539 Merge pull request #26 from plone/pre-commit-ci-update-config [pre-commit.ci] pre-commit autoupdate Files changed: M .pre-commit-config.yaml --- last_commit.txt | 71 +++++++++++++------------------------------------ 1 file changed, 19 insertions(+), 52 deletions(-) diff --git a/last_commit.txt b/last_commit.txt index 61d7379c45..fa9870a114 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -1,68 +1,35 @@ -Repository: Products.CMFPlone +Repository: plone.indexer -Branch: refs/heads/6.0.x -Date: 2024-10-08T14:35:15+02:00 -Author: Johannes Raggam (thet) -Commit: https://github.com/plone/Products.CMFPlone/commit/c41e88f93c65155f208e0e708b09440644cc851f +Branch: refs/heads/master +Date: 2024-10-07T21:24:17Z +Author: pre-commit-ci[bot] (pre-commit-ci[bot]) <66853113+pre-commit-ci[bot]@users.noreply.github.com> +Commit: https://github.com/plone/plone.indexer/commit/161c2f239dfb12f73dbd4567ff6577c2ae5f6076 -Resource registry: Support OFS.Image.File objects. +[pre-commit.ci] pre-commit autoupdate -Files changed: -A news/4022.bugfix -M Products/CMFPlone/resources/utils.py - -b'diff --git a/Products/CMFPlone/resources/utils.py b/Products/CMFPlone/resources/utils.py\nindex e72f9553fe..4230758625 100644\n--- a/Products/CMFPlone/resources/utils.py\n+++ b/Products/CMFPlone/resources/utils.py\n@@ -69,7 +69,10 @@ def get_resource(context, path):\n if hasattr(aq_base(resource), "GET"):\n # for FileResource\n result = resource.GET()\n- else:\n+ elif resource.__module__ == "OFS.Image" and resource.__class__.__name__ == "File":\n+ # A regular File object\n+ result = resource.data\n+ elif callable(resource):\n # any BrowserView\n result = resource()\n context.REQUEST.response = response_before\ndiff --git a/news/4022.bugfix b/news/4022.bugfix\nnew file mode 100644\nindex 0000000000..23d8158d8b\n--- /dev/null\n+++ b/news/4022.bugfix\n@@ -0,0 +1,2 @@\n+Resource registry: Support OFS.Image.File objects.\n+[thet]\n' - -Repository: Products.CMFPlone - - -Branch: refs/heads/6.0.x -Date: 2024-10-09T11:11:25+02:00 -Author: ale-rt (ale-rt) -Commit: https://github.com/plone/Products.CMFPlone/commit/fced377e171471e7be4c5381a20f9a616e58c9d4 - -Add test and better check - -Files changed: -M Products/CMFPlone/resources/utils.py -M Products/CMFPlone/tests/testResourceRegistries.py - -b'diff --git a/Products/CMFPlone/resources/utils.py b/Products/CMFPlone/resources/utils.py\nindex 4230758625..98e1d8763e 100644\n--- a/Products/CMFPlone/resources/utils.py\n+++ b/Products/CMFPlone/resources/utils.py\n@@ -1,6 +1,7 @@\n from Acquisition import aq_base\n from Acquisition import aq_inner\n from Acquisition import aq_parent\n+from OFS.Image import File\n from plone.base.interfaces.resources import OVERRIDE_RESOURCE_DIRECTORY_NAME\n from plone.resource.file import FilesystemFile\n from plone.resource.interfaces import IResourceDirectory\n@@ -69,8 +70,8 @@ def get_resource(context, path):\n if hasattr(aq_base(resource), "GET"):\n # for FileResource\n result = resource.GET()\n- elif resource.__module__ == "OFS.Image" and resource.__class__.__name__ == "File":\n- # A regular File object\n+ elif isinstance(resource, File):\n+ # An OFS.Image.File object\n result = resource.data\n elif callable(resource):\n # any BrowserView\ndiff --git a/Products/CMFPlone/tests/testResourceRegistries.py b/Products/CMFPlone/tests/testResourceRegistries.py\nindex 29ae11ae00..3e7bcf6388 100644\n--- a/Products/CMFPlone/tests/testResourceRegistries.py\n+++ b/Products/CMFPlone/tests/testResourceRegistries.py\n@@ -180,6 +180,29 @@ def test_bundle_depends_on_missing(self):\n # bundle should be skipped when rendering\n self.assertNotIn("http://foo.bar/foobar.js", results)\n \n+ def test_resource_browser_static_resource(self):\n+ from Products.CMFPlone.resources.webresource import PloneScriptResource\n+ resource = PloneScriptResource(self.portal, resource="++resource++plone-admin-ui.js")\n+ self.assertIn(\n+ b"window.onload", resource.file_data,\n+ )\n+\n+ def test_resource_ofs_file(self):\n+ from OFS.Image import File\n+ from Products.CMFPlone.resources.webresource import PloneScriptResource\n+ self.portal["foo.js"] = File("foo.js", "Title", b\'console.log()\')\n+ resource = PloneScriptResource(self.portal, resource="foo.js")\n+ self.assertEqual(\n+ resource.file_data, b\'console.log()\',\n+ )\n+\n+ def test_resource_view(self):\n+ from Products.CMFPlone.resources.webresource import PloneScriptResource\n+ resource = PloneScriptResource(self.portal, resource="@@ok")\n+ self.assertEqual(\n+ resource.file_data, b\'OK\',\n+ )\n+\n \n class TestStylesViewlet(PloneTestCase.PloneTestCase):\n def test_styles_viewlet(self):\n' - -Repository: Products.CMFPlone - - -Branch: refs/heads/6.0.x -Date: 2024-10-09T11:24:21+02:00 -Author: ale-rt (ale-rt) -Commit: https://github.com/plone/Products.CMFPlone/commit/8445e1a71c6e56e7a2aa58e1c1569cbf0dd98204 - -Add tests, logging on bogus resources and improve some checks +updates: +- [github.com/psf/black: 24.8.0 → 24.10.0](https://github.com/psf/black/compare/24.8.0...24.10.0) Files changed: -M Products/CMFPlone/resources/utils.py -M Products/CMFPlone/tests/testResourceRegistries.py -M news/4022.bugfix +M .pre-commit-config.yaml -b'diff --git a/Products/CMFPlone/resources/utils.py b/Products/CMFPlone/resources/utils.py\nindex 98e1d8763e..8282513ac0 100644\n--- a/Products/CMFPlone/resources/utils.py\n+++ b/Products/CMFPlone/resources/utils.py\n@@ -76,6 +76,9 @@ def get_resource(context, path):\n elif callable(resource):\n # any BrowserView\n result = resource()\n+ else:\n+ logger.info("Cannot get data from resource %r", resource)\n+ result = b""\n context.REQUEST.response = response_before\n return result\n \ndiff --git a/Products/CMFPlone/tests/testResourceRegistries.py b/Products/CMFPlone/tests/testResourceRegistries.py\nindex 3e7bcf6388..985532653b 100644\n--- a/Products/CMFPlone/tests/testResourceRegistries.py\n+++ b/Products/CMFPlone/tests/testResourceRegistries.py\n@@ -1,3 +1,4 @@\n+from OFS.Image import File\n from plone.app.testing import logout\n from plone.app.testing import setRoles\n from plone.app.testing import SITE_OWNER_NAME\n@@ -13,6 +14,7 @@\n from Products.CMFPlone.resources.browser.resource import REQUEST_CACHE_KEY\n from Products.CMFPlone.resources.browser.resource import ScriptsView\n from Products.CMFPlone.resources.browser.resource import StylesView\n+from Products.CMFPlone.resources.webresource import PloneScriptResource\n from Products.CMFPlone.tests import PloneTestCase\n from zope.component import getUtility\n \n@@ -181,15 +183,12 @@ def test_bundle_depends_on_missing(self):\n self.assertNotIn("http://foo.bar/foobar.js", results)\n \n def test_resource_browser_static_resource(self):\n- from Products.CMFPlone.resources.webresource import PloneScriptResource\n resource = PloneScriptResource(self.portal, resource="++resource++plone-admin-ui.js")\n self.assertIn(\n b"window.onload", resource.file_data,\n )\n \n def test_resource_ofs_file(self):\n- from OFS.Image import File\n- from Products.CMFPlone.resources.webresource import PloneScriptResource\n self.portal["foo.js"] = File("foo.js", "Title", b\'console.log()\')\n resource = PloneScriptResource(self.portal, resource="foo.js")\n self.assertEqual(\n@@ -197,12 +196,16 @@ def test_resource_ofs_file(self):\n )\n \n def test_resource_view(self):\n- from Products.CMFPlone.resources.webresource import PloneScriptResource\n resource = PloneScriptResource(self.portal, resource="@@ok")\n self.assertEqual(\n resource.file_data, b\'OK\',\n )\n \n+ def test_resource_bogus(self):\n+ resource = PloneScriptResource(self.portal, resource="I_do_not_exist")\n+ self.assertEqual(\n+ resource.file_data, b\'I_do_not_exist\',\n+ )\n \n class TestStylesViewlet(PloneTestCase.PloneTestCase):\n def test_styles_viewlet(self):\ndiff --git a/news/4022.bugfix b/news/4022.bugfix\nindex 23d8158d8b..292aac9553 100644\n--- a/news/4022.bugfix\n+++ b/news/4022.bugfix\n@@ -1,2 +1,2 @@\n Resource registry: Support OFS.Image.File objects.\n-[thet]\n+[ale-rt, thet]\n' +b'diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml\nindex 1460326..f70417d 100644\n--- a/.pre-commit-config.yaml\n+++ b/.pre-commit-config.yaml\n@@ -16,7 +16,7 @@ repos:\n hooks:\n - id: isort\n - repo: https://github.com/psf/black\n- rev: 24.8.0\n+ rev: 24.10.0\n hooks:\n - id: black\n - repo: https://github.com/collective/zpretty\n' -Repository: Products.CMFPlone +Repository: plone.indexer -Branch: refs/heads/6.0.x -Date: 2024-10-10T00:14:00+02:00 -Author: Johannes Raggam (thet) -Commit: https://github.com/plone/Products.CMFPlone/commit/044e2e6c8ca599ba33a049ec282669a6b53fe4b3 +Branch: refs/heads/master +Date: 2024-10-13T00:09:54+02:00 +Author: Gil Forcada Codinachs (gforcada) +Commit: https://github.com/plone/plone.indexer/commit/1cc8ef81f83ea9361ca1d767e69a166e9edeb539 -Merge pull request #4022 from plone/fix-ofs-resource +Merge pull request #26 from plone/pre-commit-ci-update-config -[6.0] Restore the capability of the resource registry to serve OFS files as resources +[pre-commit.ci] pre-commit autoupdate Files changed: -A news/4022.bugfix -M Products/CMFPlone/resources/utils.py -M Products/CMFPlone/tests/testResourceRegistries.py +M .pre-commit-config.yaml -b'diff --git a/Products/CMFPlone/resources/utils.py b/Products/CMFPlone/resources/utils.py\nindex e72f9553fe..8282513ac0 100644\n--- a/Products/CMFPlone/resources/utils.py\n+++ b/Products/CMFPlone/resources/utils.py\n@@ -1,6 +1,7 @@\n from Acquisition import aq_base\n from Acquisition import aq_inner\n from Acquisition import aq_parent\n+from OFS.Image import File\n from plone.base.interfaces.resources import OVERRIDE_RESOURCE_DIRECTORY_NAME\n from plone.resource.file import FilesystemFile\n from plone.resource.interfaces import IResourceDirectory\n@@ -69,9 +70,15 @@ def get_resource(context, path):\n if hasattr(aq_base(resource), "GET"):\n # for FileResource\n result = resource.GET()\n- else:\n+ elif isinstance(resource, File):\n+ # An OFS.Image.File object\n+ result = resource.data\n+ elif callable(resource):\n # any BrowserView\n result = resource()\n+ else:\n+ logger.info("Cannot get data from resource %r", resource)\n+ result = b""\n context.REQUEST.response = response_before\n return result\n \ndiff --git a/Products/CMFPlone/tests/testResourceRegistries.py b/Products/CMFPlone/tests/testResourceRegistries.py\nindex 29ae11ae00..985532653b 100644\n--- a/Products/CMFPlone/tests/testResourceRegistries.py\n+++ b/Products/CMFPlone/tests/testResourceRegistries.py\n@@ -1,3 +1,4 @@\n+from OFS.Image import File\n from plone.app.testing import logout\n from plone.app.testing import setRoles\n from plone.app.testing import SITE_OWNER_NAME\n@@ -13,6 +14,7 @@\n from Products.CMFPlone.resources.browser.resource import REQUEST_CACHE_KEY\n from Products.CMFPlone.resources.browser.resource import ScriptsView\n from Products.CMFPlone.resources.browser.resource import StylesView\n+from Products.CMFPlone.resources.webresource import PloneScriptResource\n from Products.CMFPlone.tests import PloneTestCase\n from zope.component import getUtility\n \n@@ -180,6 +182,30 @@ def test_bundle_depends_on_missing(self):\n # bundle should be skipped when rendering\n self.assertNotIn("http://foo.bar/foobar.js", results)\n \n+ def test_resource_browser_static_resource(self):\n+ resource = PloneScriptResource(self.portal, resource="++resource++plone-admin-ui.js")\n+ self.assertIn(\n+ b"window.onload", resource.file_data,\n+ )\n+\n+ def test_resource_ofs_file(self):\n+ self.portal["foo.js"] = File("foo.js", "Title", b\'console.log()\')\n+ resource = PloneScriptResource(self.portal, resource="foo.js")\n+ self.assertEqual(\n+ resource.file_data, b\'console.log()\',\n+ )\n+\n+ def test_resource_view(self):\n+ resource = PloneScriptResource(self.portal, resource="@@ok")\n+ self.assertEqual(\n+ resource.file_data, b\'OK\',\n+ )\n+\n+ def test_resource_bogus(self):\n+ resource = PloneScriptResource(self.portal, resource="I_do_not_exist")\n+ self.assertEqual(\n+ resource.file_data, b\'I_do_not_exist\',\n+ )\n \n class TestStylesViewlet(PloneTestCase.PloneTestCase):\n def test_styles_viewlet(self):\ndiff --git a/news/4022.bugfix b/news/4022.bugfix\nnew file mode 100644\nindex 0000000000..292aac9553\n--- /dev/null\n+++ b/news/4022.bugfix\n@@ -0,0 +1,2 @@\n+Resource registry: Support OFS.Image.File objects.\n+[ale-rt, thet]\n' +b'diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml\nindex 1460326..f70417d 100644\n--- a/.pre-commit-config.yaml\n+++ b/.pre-commit-config.yaml\n@@ -16,7 +16,7 @@ repos:\n hooks:\n - id: isort\n - repo: https://github.com/psf/black\n- rev: 24.8.0\n+ rev: 24.10.0\n hooks:\n - id: black\n - repo: https://github.com/collective/zpretty\n'