From 21eee98c295c64337d534f591c1680426d3d45b9 Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Sun, 19 Jan 2025 00:09:52 +0100 Subject: [PATCH] Fix DeprecationWarnings. --- news/4090.bugfix | 1 + plone/app/portlets/browser/configure.zcml | 2 +- plone/app/portlets/dashboard/configure.zcml | 4 ++-- plone/app/portlets/portlets/navigation.py | 12 ++++++------ plone/app/portlets/portlets/news.py | 14 ++++++++++---- plone/app/portlets/portlets/recent.py | 4 ++-- plone/app/portlets/portlets/search.py | 4 ++-- .../app/portlets/tests/test_navigation_portlet.py | 2 +- 8 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 news/4090.bugfix diff --git a/news/4090.bugfix b/news/4090.bugfix new file mode 100644 index 00000000..8528aefb --- /dev/null +++ b/news/4090.bugfix @@ -0,0 +1 @@ +Fix DeprecationWarnings. [maurits] diff --git a/plone/app/portlets/browser/configure.zcml b/plone/app/portlets/browser/configure.zcml index a06c00c8..71b7a7ba 100644 --- a/plone/app/portlets/browser/configure.zcml +++ b/plone/app/portlets/browser/configure.zcml @@ -91,7 +91,7 @@ 0: diff --git a/plone/app/portlets/portlets/news.py b/plone/app/portlets/portlets/news.py index ebb7d97b..66a2e7c1 100644 --- a/plone/app/portlets/portlets/news.py +++ b/plone/app/portlets/portlets/news.py @@ -2,10 +2,9 @@ from ..cache import render_cachekey from ..portlets import base from Acquisition import aq_inner -from plone.app.layout.navigation.root import getNavigationRootObject -from plone.app.z3cform.widget import SelectFieldWidget from plone.autoform.directives import widget from plone.base.interfaces import ISiteSchema +from plone.base.navigationroot import get_navigation_root_object from plone.memoize import ram from plone.memoize.compress import xhtml_compress from plone.memoize.instance import memoize @@ -19,6 +18,13 @@ from zope.interface import implementer +try: + from plone.app.z3cform.widgets.select import Select2FieldWidget +except ImportError: + # BBB Plone 6.0 + from plone.app.z3cform.widget import SelectFieldWidget as Select2FieldWidget + + class INewsPortlet(IPortletDataProvider): count = schema.Int( title=_("Number of items to display"), @@ -28,7 +34,7 @@ class INewsPortlet(IPortletDataProvider): min=1, ) - widget(state=SelectFieldWidget) + widget(state=Select2FieldWidget) state = schema.Tuple( title=_("Workflow state"), description=_("Items in which workflow state to show."), @@ -98,7 +104,7 @@ def all_news_link(self): (context, self.request), name="plone_portal_state" ) portal = portal_state.portal() - if "news" in getNavigationRootObject(context, portal).objectIds(): + if "news" in get_navigation_root_object(context, portal).objectIds(): return "%s/news" % portal_state.navigation_root_url() return None diff --git a/plone/app/portlets/portlets/recent.py b/plone/app/portlets/portlets/recent.py index 05e7d74a..904d6b90 100644 --- a/plone/app/portlets/portlets/recent.py +++ b/plone/app/portlets/portlets/recent.py @@ -2,8 +2,8 @@ from ..cache import render_cachekey from ..portlets import base from Acquisition import aq_inner -from plone.app.layout.navigation.root import getNavigationRoot from plone.base.interfaces.controlpanel import ISiteSchema +from plone.base.navigationroot import get_navigation_root from plone.memoize import ram from plone.memoize.compress import xhtml_compress from plone.memoize.instance import memoize @@ -145,7 +145,7 @@ def thumb_scale(self): def getMimeTypeIcon(self, obj): fileo = obj.getObject().file - portal_url = getNavigationRoot(self.context) + portal_url = get_navigation_root(self.context) mtt = getToolByName(self.context, "mimetypes_registry") if fileo.contentType: ctype = mtt.lookup(fileo.contentType) diff --git a/plone/app/portlets/portlets/search.py b/plone/app/portlets/portlets/search.py index 18a45998..1c298f0b 100644 --- a/plone/app/portlets/portlets/search.py +++ b/plone/app/portlets/portlets/search.py @@ -1,6 +1,6 @@ from .. import PloneMessageFactory as _ from ..portlets import base -from plone.app.layout.navigation.root import getNavigationRoot +from plone.base.navigationroot import get_navigation_root from plone.portlets.interfaces import IPortletDataProvider from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from zope import schema @@ -51,7 +51,7 @@ def search_action(self): return f"{self.navigation_root_url}/{self.action}" def navigation_root_url(self): - return getNavigationRoot(self.context) + return get_navigation_root(self.context) class AddForm(base.AddForm): diff --git a/plone/app/portlets/tests/test_navigation_portlet.py b/plone/app/portlets/tests/test_navigation_portlet.py index e917df34..0a55bc72 100644 --- a/plone/app/portlets/tests/test_navigation_portlet.py +++ b/plone/app/portlets/tests/test_navigation_portlet.py @@ -1,11 +1,11 @@ from five.intid.intid import IntIds from five.intid.site import addUtility -from plone.app.layout.navigation.interfaces import INavigationRoot from plone.app.portlets.portlets import navigation from plone.app.portlets.storage import PortletAssignmentMapping from plone.app.portlets.tests.base import PortletsTestCase from plone.app.testing import setRoles from plone.app.testing import TEST_USER_ID +from plone.base.interfaces import INavigationRoot from plone.base.interfaces import INavigationSchema from plone.portlets.interfaces import IPortletAssignment from plone.portlets.interfaces import IPortletDataProvider