From 65913e9de7a7e136bf12dabe1a57d1d148643cc8 Mon Sep 17 00:00:00 2001 From: wesleybl Date: Tue, 5 Mar 2024 17:00:09 -0300 Subject: [PATCH] Use version marker to define if is Plone 6 --- src/plone/restapi/__init__.py | 6 ++++-- src/plone/restapi/imaging.py | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plone/restapi/__init__.py b/src/plone/restapi/__init__.py index 1af372090..c2cd6a1bb 100644 --- a/src/plone/restapi/__init__.py +++ b/src/plone/restapi/__init__.py @@ -1,8 +1,8 @@ from . import patches # noqa: ignore=F401 from AccessControl import allow_module from AccessControl.Permissions import add_user_folders +from importlib import import_module from plone.restapi.pas import plugin -from Products.CMFPlone.utils import getFSVersionTuple from Products.PluggableAuthService.PluggableAuthService import registerMultiPlugin from zope.i18nmessageid import MessageFactory @@ -22,7 +22,9 @@ allow_module("json") # BBB: Plone 5.2 -PLONE5 = getFSVersionTuple()[0] == 5 +HAS_PLONE_6 = getattr( + import_module("Products.CMFPlone.factory"), "PLONE60MARKER", False +) def initialize(context): diff --git a/src/plone/restapi/imaging.py b/src/plone/restapi/imaging.py index bbb3cd52b..984fc88fa 100644 --- a/src/plone/restapi/imaging.py +++ b/src/plone/restapi/imaging.py @@ -1,15 +1,15 @@ -from plone.restapi import PLONE5 +from plone.restapi import HAS_PLONE_6 from zope.component import getMultiAdapter from zope.component import getUtility from zope.globalrequest import getRequest -if PLONE5: - # BBB: In Plone 5.2, it is necessary to use the direction parameter. - scale_parameter = {"direction": "thumbnail"} -else: +if HAS_PLONE_6: # In Plone 6.0+, we must use the mode parameter scale_parameter = {"mode": "scale"} +else: + # BBB: In Plone 5.2, it is necessary to use the direction parameter. + scale_parameter = {"direction": "thumbnail"} def get_scales(context, field, width, height):