From e3f3e397135cb40f2409b84df4fd8d3a5335a766 Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Wed, 22 Jan 2025 23:59:27 +0100 Subject: [PATCH] Support `icalendar` 6 by forcing it to use its `pytz` timezone implementation. The new `zoneinfo` support in `icalendar` 6 does not work for us yet, giving indexing problems. So we call `icalendar.use_pytz` at startup. If this fails, we must be using an older version where `pytz` is the only option anyway, so we ignore this. --- news/6.bugfix | 5 +++++ plone/app/event/__init__.py | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 news/6.bugfix diff --git a/news/6.bugfix b/news/6.bugfix new file mode 100644 index 00000000..b000847d --- /dev/null +++ b/news/6.bugfix @@ -0,0 +1,5 @@ +Support ``icalendar`` 6 by forcing it to use its ``pytz`` timezone implementation. +The new ``zoneinfo`` support in ``icalendar`` 6 does not work for us yet, giving indexing problems. +So we call ``icalendar.use_pytz`` at startup. +If this fails, we must be using an older version where ``pytz`` is the only option anyway, so we ignore this. +[maurits] diff --git a/plone/app/event/__init__.py b/plone/app/event/__init__.py index bac87e2c..62ed906e 100644 --- a/plone/app/event/__init__.py +++ b/plone/app/event/__init__.py @@ -1,10 +1,27 @@ from AccessControl.Permission import addPermission from zope.i18nmessageid import MessageFactory +import icalendar +import logging + +logger = logging.getLogger(__name__) packageName = __name__ _ = MessageFactory("plone") +# We are not yet ready to use the standard zoneinfo implementation +# introduced in icalendar 6. For starters, the tests fail when +# Products.DateRecurringIndex.index.index_object is called: +# SystemError: returned a result with an exception set +try: + icalendar.use_pytz() + logger.info("icalendar has been set up to use pytz instead of zoneinfo.") +except AttributeError: + # If use_pytz does not exist, we either have an older icalender version + # that only supports pytz anyway, or we have a newer version that no + # longer supports it at all. + pass + # BBB Permissions PORTAL_ADD_PERMISSION = "Add portal events" # CMFCalendar/ATCT permissions