-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/master Date: 2023-09-19T17:29:30+02:00 Author: Maurits van Rees (mauritsvanrees) <[email protected]> Commit: plone/Products.CMFPlone@8c0daf6 Register site syndication settings from plone.base instead of CMFPlone. Files changed: A news/315.bugfix M Products/CMFPlone/profiles/dependencies/registry.xml
- Loading branch information
1 parent
85543dc
commit d3a84a8
Showing
1 changed file
with
6 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,16 @@ | ||
Repository: plone.app.upgrade | ||
Repository: Products.CMFPlone | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2023-09-19T16:04:59+02:00 | ||
Date: 2023-09-19T17:29:30+02:00 | ||
Author: Maurits van Rees (mauritsvanrees) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.upgrade/commit/c8cd2b7cd95a80b021b1295552c6b6824aa3f1fc | ||
Commit: https://github.com/plone/Products.CMFPlone/commit/8c0daf696c88aefbe9b2dcfd51bab950625d8e9e | ||
|
||
Fix error in site syndication settings when upgrading. | ||
|
||
Fixes https://github.com/plone/plone.app.upgrade/issues/315 | ||
|
||
Files changed: | ||
A news/315.bugfix | ||
M plone/app/upgrade/v60/final.py | ||
|
||
b'diff --git a/news/315.bugfix b/news/315.bugfix\nnew file mode 100644\nindex 00000000..af38c1f6\n--- /dev/null\n+++ b/news/315.bugfix\n@@ -0,0 +1,2 @@\n+Fix error in site syndication settings when upgrading.\n+[maurits]\ndiff --git a/plone/app/upgrade/v60/final.py b/plone/app/upgrade/v60/final.py\nindex 6d994f97..7e756f40 100644\n--- a/plone/app/upgrade/v60/final.py\n+++ b/plone/app/upgrade/v60/final.py\n@@ -141,12 +141,18 @@ def fix_tinymce_menubar(context):\n record.value = value\n \n def fix_syndication_settings(context):\n- """Fix Syndication Setting in the registry \n+ """Fix Syndication Setting in the registry\n Products.CMFPlone.interfaces.syndication.ISiteSyndicationSettings\n is moved to plone.base.interfaces.syndication.ISiteSyndicationSettings.\n \n See https://github.com/plone/Products.CMFPlone/issues/3805\n """\n+ try:\n+ from plone.base.interfaces.syndication import ISiteSyndicationSettings\n+ except ImportError:\n+ # Upgrade step called from older Plone version?\n+ return\n+\n registry = getUtility(IRegistry)\n record_keys = list(registry.records.keys())\n portal_catalog = getToolByName(context,\'portal_catalog\')\n@@ -171,6 +177,9 @@ def fix_syndication_settings(context):\n "show_syndication_link"\n ]\n \n+ # Make sure the interface is registered\n+ registry.registerInterface(ISiteSyndicationSettings)\n+\n # write old record values to new record\n for fieldname in fieldnames:\n old_key = f"{old_iface}.{fieldname}"\n' | ||
|
||
Repository: plone.app.upgrade | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2023-09-19T16:38:40+02:00 | ||
Author: Maurits van Rees (mauritsvanrees) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.upgrade/commit/e7877a7a29b719ad2b369b215f0598ba5cce8e6b | ||
|
||
site syndication: fix TypeError when site_rss_items value is None. | ||
|
||
I ran `black` as well. The real change is on this line: | ||
|
||
items = list(record.value) if record.value else () | ||
|
||
Traceback: | ||
|
||
``` | ||
Traceback (most recent call last): | ||
File "/Users/maurits/shared-eggs/cp310/Products.CMFPlone-6.0.7rc1-py3.10.egg/Products/CMFPlone/MigrationTool.py", line 289, in upgrade | ||
step["step"].doStep(setup) | ||
File "/Users/maurits/shared-eggs/cp310/Products.GenericSetup-3.0.1-py3.10.egg/Products/GenericSetup/upgrade.py", line 193, in doStep | ||
self.handler(tool) | ||
File "/Users/maurits/shared-eggs/cp310/plone.app.upgrade-3.0.7-py3.10.egg/plone/app/upgrade/v60/final.py", line 183, in fix_syndication_settings | ||
items = list(record.value) | ||
TypeError: 'NoneType' object is not iterable | ||
``` | ||
|
||
Files changed: | ||
M plone/app/upgrade/v60/final.py | ||
|
||
b'diff --git a/plone/app/upgrade/v60/final.py b/plone/app/upgrade/v60/final.py\nindex 7e756f40..4b6479d2 100644\n--- a/plone/app/upgrade/v60/final.py\n+++ b/plone/app/upgrade/v60/final.py\n@@ -140,6 +140,7 @@ def fix_tinymce_menubar(context):\n value.insert(index, "tools")\n record.value = value\n \n+\n def fix_syndication_settings(context):\n """Fix Syndication Setting in the registry\n Products.CMFPlone.interfaces.syndication.ISiteSyndicationSettings\n@@ -155,16 +156,16 @@ def fix_syndication_settings(context):\n \n registry = getUtility(IRegistry)\n record_keys = list(registry.records.keys())\n- portal_catalog = getToolByName(context,\'portal_catalog\')\n+ portal_catalog = getToolByName(context, "portal_catalog")\n \n portal_url = getToolByName(context, "portal_url")\n portal = portal_url.getPortalObject()\n path = "/".join(portal.getPhysicalPath())\n \n old_iface = "Products.CMFPlone.interfaces.syndication.ISiteSyndicationSettings"\n- new_iface ="plone.base.interfaces.syndication.ISiteSyndicationSettings"\n+ new_iface = "plone.base.interfaces.syndication.ISiteSyndicationSettings"\n \n- fieldnames=[\n+ fieldnames = [\n "allowed",\n "default_enabled",\n "search_rss_enabled",\n@@ -174,7 +175,7 @@ def fix_syndication_settings(context):\n "allowed_feed_types",\n "site_rss_items",\n "show_syndication_button",\n- "show_syndication_link"\n+ "show_syndication_link",\n ]\n \n # Make sure the interface is registered\n@@ -186,23 +187,22 @@ def fix_syndication_settings(context):\n new_key = f"{new_iface}.{fieldname}"\n record = registry.records.get(old_key)\n if record is not None:\n- if fieldname == \'site_rss_items\':\n+ if fieldname == "site_rss_items":\n # handle none existing items\n # if in path in catalog add to the record\n- items = list(record.value)\n- newitems=[]\n+ items = list(record.value) if record.value else ()\n+ newitems = []\n for item in items:\n- brains = portal_catalog(path={ "query": f"{path}{item}", "depth": 0}) \n+ brains = portal_catalog(path={"query": f"{path}{item}", "depth": 0})\n if len(brains) > 0:\n brain = brains[0]\n- newitems.append(brain.UID) \n+ newitems.append(brain.UID)\n registry[new_key] = tuple(newitems)\n else:\n registry[new_key] = record.value\n \n-\n # delete the old records\n for fieldname in fieldnames:\n key = f"{old_iface}.{fieldname}"\n if key in record_keys:\n- del registry.records[key]\n\\ No newline at end of file\n+ del registry.records[key]\n' | ||
|
||
Repository: plone.app.upgrade | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2023-09-19T17:28:32+02:00 | ||
Author: Maurits van Rees (mauritsvanrees) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.upgrade/commit/bbdc8d7384d010957cf6916b44265b8e0b9bc9f2 | ||
|
||
Merge pull request #318 from plone/maurits-syndication | ||
|
||
Fix error in site syndication settings when upgrading. | ||
Register site syndication settings from plone.base instead of CMFPlone. | ||
|
||
Files changed: | ||
A news/315.bugfix | ||
M plone/app/upgrade/v60/final.py | ||
M Products/CMFPlone/profiles/dependencies/registry.xml | ||
|
||
b'diff --git a/news/315.bugfix b/news/315.bugfix\nnew file mode 100644\nindex 00000000..af38c1f6\n--- /dev/null\n+++ b/news/315.bugfix\n@@ -0,0 +1,2 @@\n+Fix error in site syndication settings when upgrading.\n+[maurits]\ndiff --git a/plone/app/upgrade/v60/final.py b/plone/app/upgrade/v60/final.py\nindex 6d994f97..4b6479d2 100644\n--- a/plone/app/upgrade/v60/final.py\n+++ b/plone/app/upgrade/v60/final.py\n@@ -140,25 +140,32 @@ def fix_tinymce_menubar(context):\n value.insert(index, "tools")\n record.value = value\n \n+\n def fix_syndication_settings(context):\n- """Fix Syndication Setting in the registry \n+ """Fix Syndication Setting in the registry\n Products.CMFPlone.interfaces.syndication.ISiteSyndicationSettings\n is moved to plone.base.interfaces.syndication.ISiteSyndicationSettings.\n \n See https://github.com/plone/Products.CMFPlone/issues/3805\n """\n+ try:\n+ from plone.base.interfaces.syndication import ISiteSyndicationSettings\n+ except ImportError:\n+ # Upgrade step called from older Plone version?\n+ return\n+\n registry = getUtility(IRegistry)\n record_keys = list(registry.records.keys())\n- portal_catalog = getToolByName(context,\'portal_catalog\')\n+ portal_catalog = getToolByName(context, "portal_catalog")\n \n portal_url = getToolByName(context, "portal_url")\n portal = portal_url.getPortalObject()\n path = "/".join(portal.getPhysicalPath())\n \n old_iface = "Products.CMFPlone.interfaces.syndication.ISiteSyndicationSettings"\n- new_iface ="plone.base.interfaces.syndication.ISiteSyndicationSettings"\n+ new_iface = "plone.base.interfaces.syndication.ISiteSyndicationSettings"\n \n- fieldnames=[\n+ fieldnames = [\n "allowed",\n "default_enabled",\n "search_rss_enabled",\n@@ -168,32 +175,34 @@ def fix_syndication_settings(context):\n "allowed_feed_types",\n "site_rss_items",\n "show_syndication_button",\n- "show_syndication_link"\n+ "show_syndication_link",\n ]\n \n+ # Make sure the interface is registered\n+ registry.registerInterface(ISiteSyndicationSettings)\n+\n # write old record values to new record\n for fieldname in fieldnames:\n old_key = f"{old_iface}.{fieldname}"\n new_key = f"{new_iface}.{fieldname}"\n record = registry.records.get(old_key)\n if record is not None:\n- if fieldname == \'site_rss_items\':\n+ if fieldname == "site_rss_items":\n # handle none existing items\n # if in path in catalog add to the record\n- items = list(record.value)\n- newitems=[]\n+ items = list(record.value) if record.value else ()\n+ newitems = []\n for item in items:\n- brains = portal_catalog(path={ "query": f"{path}{item}", "depth": 0}) \n+ brains = portal_catalog(path={"query": f"{path}{item}", "depth": 0})\n if len(brains) > 0:\n brain = brains[0]\n- newitems.append(brain.UID) \n+ newitems.append(brain.UID)\n registry[new_key] = tuple(newitems)\n else:\n registry[new_key] = record.value\n \n-\n # delete the old records\n for fieldname in fieldnames:\n key = f"{old_iface}.{fieldname}"\n if key in record_keys:\n- del registry.records[key]\n\\ No newline at end of file\n+ del registry.records[key]\n' | ||
b'diff --git a/Products/CMFPlone/profiles/dependencies/registry.xml b/Products/CMFPlone/profiles/dependencies/registry.xml\nindex 865653a149..0a65468523 100644\n--- a/Products/CMFPlone/profiles/dependencies/registry.xml\n+++ b/Products/CMFPlone/profiles/dependencies/registry.xml\n@@ -103,7 +103,7 @@\n <element>plone.dashboard4</element>\n </value>\n </record>\n- <records interface="Products.CMFPlone.interfaces.syndication.ISiteSyndicationSettings" />\n+ <records interface="plone.base.interfaces.syndication.ISiteSyndicationSettings" />\n \n <!-- Plone resource registry -->\n <record name="plone.resources.development">\ndiff --git a/news/315.bugfix b/news/315.bugfix\nnew file mode 100644\nindex 0000000000..90c7dd6efe\n--- /dev/null\n+++ b/news/315.bugfix\n@@ -0,0 +1,2 @@\n+Register site syndication settings from plone.base instead of CMFPlone.\n+[maurits]\n' | ||
|