Skip to content

Commit

Permalink
[fc] Repository: plone.event
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2023-09-18T16:07:30+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: plone/plone.event@186c070

ignore dtstart and until time in rrule (#23)

Ignore dtstart and until time in rrule in recurrence_sequence_ical.

In recurrence_sequence_ical, the DTSTART in the recrule is used for all occurrences that follow the first one. This is a design issue because the start time is a mandatory parameter, and its time must be used for every occurrence, by design.

For the same reason, the time in the UNTIL field must always be ignored.

Problems occur, for example, with the rrule widget in Volto (see also plone/volto#5002), which consistently returns a DTSTART and UNTIL field inside the recrule with a timezone (UTC).

Files changed:
A news/23.bugfix
M plone/event/recurrence.py
M plone/event/tests/test_recurrence_sequence_ical.py
  • Loading branch information
thet committed Sep 18, 2023
1 parent ab1ea4b commit 64ef5ac
Showing 1 changed file with 16 additions and 82 deletions.
98 changes: 16 additions & 82 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,91 +1,25 @@
Repository: plone.app.event
Repository: plone.event


Branch: refs/heads/master
Date: 2023-09-07T15:13:55+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/plone.app.event/commit/86c775628ece5bedb0824402de8d1c6a2feec527
Date: 2023-09-18T16:07:30+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: https://github.com/plone/plone.event/commit/186c0708b166e419b1b018eaaada6023025ce310

Require setuptools 68.2 or higher for building the package.
ignore dtstart and until time in rrule (#23)

When built with setuptools 68.1, you could not import the package, at least not an editable package.
Note that you can still *install* this package with older setuptools versions.
See [Plone meta issue 172](https://github.com/plone/meta/issues/172) for details.

New problem though. `tox -e dependencies` says:

```
ERROR Missing dependencies:
setuptools&gt;=68.2
```

I tried with `setuptools&lt;68.1', which would also work, but that only changes the message:

```
ERROR Missing dependencies:
setuptools&lt;68.1
```

I think this is a shortcoming in `z3c.dependencychecker`. It should not report this as a missing dependency.
It should see that `pyproject.toml` has this dependency covered.

We definitely should *not* require `setuptools&gt;=68.2` in `install_requires`.

Files changed:
A news/172.internal
M pyproject.toml

b'diff --git a/news/172.internal b/news/172.internal\nnew file mode 100644\nindex 000000000..6a54c5491\n--- /dev/null\n+++ b/news/172.internal\n@@ -0,0 +1,5 @@\n+Require setuptools 68.2 or higher for building the package.\n+When built with setuptools 68.1, you could not import the package, at least not an editable package.\n+Note that you can still *install* this package with older setuptools versions.\n+See `Plone meta issue 172 <https://github.com/plone/meta/issues/172>`_ for details.\n+[maurits]\ndiff --git a/pyproject.toml b/pyproject.toml\nindex 4f15ca58f..fd2ab3e2c 100644\n--- a/pyproject.toml\n+++ b/pyproject.toml\n@@ -1,6 +1,9 @@\n # Generated from:\n # https://github.com/plone/meta/tree/master/config/default\n # See the inline comments on how to expand/tweak this configuration file\n+[build-system]\n+requires = ["setuptools>=68.2", "wheel"]\n+\n [tool.towncrier]\n directory = "news/"\n filename = "CHANGES.rst"\n'

Repository: plone.app.event


Branch: refs/heads/master
Date: 2023-09-07T15:47:33+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/plone.app.event/commit/ce6b5c3c9d9180d966f96c57a724385730c4f1d0

tox -e dependencies: we do want isolation when building the package.

Otherwise the build command fails.
See https://github.com/reinout/z3c.dependencychecker/issues/124

Files changed:
M tox.ini

b'diff --git a/tox.ini b/tox.ini\nindex 60d323c7..16c4de19 100644\n--- a/tox.ini\n+++ b/tox.ini\n@@ -58,7 +58,7 @@ deps =\n build\n z3c.dependencychecker==2.11\n commands =\n- python -m build --sdist --no-isolation\n+ python -m build --sdist\n dependencychecker\n \n [testenv:dependencies-graph]\n'

Repository: plone.app.event


Branch: refs/heads/master
Date: 2023-09-07T15:53:11+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/plone.app.event/commit/ff5c13e759da554c607d6833ad447b25d0018620

tox: need to build with isolation in check-release env as well.

Files changed:
M tox.ini

b'diff --git a/tox.ini b/tox.ini\nindex 16c4de19..3f82c641 100644\n--- a/tox.ini\n+++ b/tox.ini\n@@ -125,7 +125,7 @@ commands =\n # we build the change log as news entries might break\n # the README that is displayed on PyPI\n towncrier build --version=100.0.0 --yes\n- python -m build --sdist --no-isolation\n+ python -m build --sdist\n twine check dist/*\n \n [testenv:circular]\n'

Repository: plone.app.event


Branch: refs/heads/master
Date: 2023-09-16T12:13:25+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/plone.app.event/commit/e040c0e3ea7f7a1458000fb15d5188f9dfb0f9bf

Merge pull request #385 from plone/maurits-minimum-setuptools-version-for-build

Require setuptools 68.2 or higher for building the package.
Ignore dtstart and until time in rrule in recurrence_sequence_ical.

In recurrence_sequence_ical, the DTSTART in the recrule is used for all occurrences that follow the first one. This is a design issue because the start time is a mandatory parameter, and its time must be used for every occurrence, by design.

For the same reason, the time in the UNTIL field must always be ignored.

Problems occur, for example, with the rrule widget in Volto (see also plone/volto#5002), which consistently returns a DTSTART and UNTIL field inside the recrule with a timezone (UTC).

Files changed:
A news/172.internal
M pyproject.toml
M tox.ini
A news/23.bugfix
M plone/event/recurrence.py
M plone/event/tests/test_recurrence_sequence_ical.py

b'diff --git a/news/172.internal b/news/172.internal\nnew file mode 100644\nindex 000000000..6a54c5491\n--- /dev/null\n+++ b/news/172.internal\n@@ -0,0 +1,5 @@\n+Require setuptools 68.2 or higher for building the package.\n+When built with setuptools 68.1, you could not import the package, at least not an editable package.\n+Note that you can still *install* this package with older setuptools versions.\n+See `Plone meta issue 172 <https://github.com/plone/meta/issues/172>`_ for details.\n+[maurits]\ndiff --git a/pyproject.toml b/pyproject.toml\nindex 4f15ca58f..fd2ab3e2c 100644\n--- a/pyproject.toml\n+++ b/pyproject.toml\n@@ -1,6 +1,9 @@\n # Generated from:\n # https://github.com/plone/meta/tree/master/config/default\n # See the inline comments on how to expand/tweak this configuration file\n+[build-system]\n+requires = ["setuptools>=68.2", "wheel"]\n+\n [tool.towncrier]\n directory = "news/"\n filename = "CHANGES.rst"\ndiff --git a/tox.ini b/tox.ini\nindex 60d323c79..3f82c641a 100644\n--- a/tox.ini\n+++ b/tox.ini\n@@ -58,7 +58,7 @@ deps =\n build\n z3c.dependencychecker==2.11\n commands =\n- python -m build --sdist --no-isolation\n+ python -m build --sdist\n dependencychecker\n \n [testenv:dependencies-graph]\n@@ -125,7 +125,7 @@ commands =\n # we build the change log as news entries might break\n # the README that is displayed on PyPI\n towncrier build --version=100.0.0 --yes\n- python -m build --sdist --no-isolation\n+ python -m build --sdist\n twine check dist/*\n \n [testenv:circular]\n'
b'diff --git a/news/23.bugfix b/news/23.bugfix\nnew file mode 100644\nindex 0000000..abd78be\n--- /dev/null\n+++ b/news/23.bugfix\n@@ -0,0 +1 @@\n+Ignore dtstart and until time in rrule in recurrence_sequence_ical [mamico]\ndiff --git a/plone/event/recurrence.py b/plone/event/recurrence.py\nindex 2900837..34a6ffe 100644\n--- a/plone/event/recurrence.py\n+++ b/plone/event/recurrence.py\n@@ -72,6 +72,14 @@ def recurrence_sequence_ical(\n duration = datetime.timedelta(0)\n \n if recrule:\n+ # We want the recurrence be calculated ignoring the DTSTART,\n+ # which is defined by the event\'s own start.\n+ # \xe2\x80\x8c Also set the UNTIL time to the end of the day to include the last\n+ # occurrence for sure.\n+ #\n+ # start is a mandatory parameter for this function, remove DTSTART\n+ # from recrule\n+ recrule = re.sub(r"DTSTART:[^;\\n]*[;\\n]", "", recrule, re.MULTILINE)\n # TODO BUGFIX WRONG TIME DEFINITIONS\n # THIS HACK ensures, that UNTIL, RDATE and EXDATE definitions with\n # incorrect time (currently always set to 0:00 by the recurrence\n@@ -93,9 +101,9 @@ def recurrence_sequence_ical(\n # subbing if the start time is already 000000.\n if t0str != "T000000":\n recrule = re.sub(r"T000000", t0str, recrule)\n- # Then, replace incorrect until times with the end of the day\n+ # Then, replace each until times with the end of the day\n recrule = re.sub(\n- r"(UNTIL[^T]*[0-9]{8})T(000000)",\n+ r"(UNTIL[^T]*[0-9]{8})T([0-9]{6}Z?)",\n r"\\1T235959",\n recrule,\n )\ndiff --git a/plone/event/tests/test_recurrence_sequence_ical.py b/plone/event/tests/test_recurrence_sequence_ical.py\nindex 25f1887..6dbe2cf 100644\n--- a/plone/event/tests/test_recurrence_sequence_ical.py\n+++ b/plone/event/tests/test_recurrence_sequence_ical.py\n@@ -180,3 +180,18 @@ def test_recrule_until_with_timezone(self):\n recrule = "RRULE:FREQ=DAILY;UNTIL=20111130T000000Z"\n seq = list(recurrence_sequence_ical(start, recrule=recrule))\n self.assertEqual(len(seq), 7)\n+\n+ def test_recrule_with_dtstart(self):\n+ from datetime import datetime\n+ from plone.event.recurrence import recurrence_sequence_ical\n+\n+ import pytz\n+\n+ at = pytz.timezone("Europe/Vienna")\n+ start = at.localize(datetime(2023, 9, 4, 1, 0))\n+ # DTSTART is ignored, because start is ever explicitly given\n+ recrule = "DTSTART:20230903T180000Z\\nRRULE:FREQ=DAILY;UNTIL=20230905T230000Z"\n+ seq = list(recurrence_sequence_ical(start, recrule=recrule))\n+ self.assertEqual(len(seq), 2)\n+ self.assertEqual(seq[0], at.localize(datetime(2023, 9, 4, 1, 0)))\n+ self.assertEqual(seq[1], at.localize(datetime(2023, 9, 5, 1, 0)))\n'

0 comments on commit 64ef5ac

Please sign in to comment.