Skip to content

Commit

Permalink
Limit event occurrences to 1000.
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Apr 8, 2024
1 parent ff608ee commit 9e5a091
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
5.4.9 (unreleased)
------------------

- Limit event occurrences to 1000.
[mamico]
- Customize INameChooser adapter to check also alias ids and disallow to create contents that could override aliases.
[cekk]
- Add flag in controlpanel to enable/disable INameChooser customization.
Expand Down
12 changes: 12 additions & 0 deletions src/redturtle/volto/monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
from zope.globalrequest import getRequest

import datetime
import logging
import os


logger = logging.getLogger(__name__)


def occurrences(self, range_start=None, range_end=None):
"""Return all occurrences of an event, possibly within a start and end
limit.
Expand Down Expand Up @@ -94,7 +98,15 @@ def get_obj(start):
id=str(start.date()), start=start, end=start + duration
).__of__(self.context)

limit = 100
for start in starts:
if limit < 0:
logger.warning(
"Too many occurrences, for %s stopping at 100",
self.context.absolute_url(),
)
raise StopIteration
limit -= 1
yield get_obj(start)


Expand Down

0 comments on commit 9e5a091

Please sign in to comment.