Skip to content

Commit

Permalink
Use version marker to define if is Plone 6
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleybl committed Mar 5, 2024
1 parent 1eb7671 commit 65913e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/plone/restapi/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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):
Expand Down
10 changes: 5 additions & 5 deletions src/plone/restapi/imaging.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down

0 comments on commit 65913e9

Please sign in to comment.