1.1 --- a/EventAggregatorSupport/Resources.py Mon Apr 07 23:16:49 2014 +0200
1.2 +++ b/EventAggregatorSupport/Resources.py Tue Apr 08 00:26:33 2014 +0200
1.3 @@ -213,6 +213,26 @@
1.4
1.5 return new_event_page.getBody()
1.6
1.7 +# Event selection using UID and SEQUENCE information.
1.8 +
1.9 +def getActiveRevisions(events):
1.10 +
1.11 + """
1.12 + Get the event instances with the greatest SEQUENCE number for each UID in
1.13 + the given 'events'.
1.14 + """
1.15 +
1.16 + active = {}
1.17 +
1.18 + for event in events:
1.19 + uid = event.getEventUID()
1.20 +
1.21 + if not active.has_key(uid) or \
1.22 + event.getSequence() > active[uid].getSequence():
1.23 + active[uid] = event
1.24 +
1.25 + return active.values()
1.26 +
1.27 # Event selection from request parameters.
1.28
1.29 def getEventsUsingParameters(category_names, search_pattern, remote_sources,
1.30 @@ -229,6 +249,7 @@
1.31 pages = getPagesFromResults(results, request)
1.32 events = getEventPages(pages).getEvents()
1.33 events += getEventResources(remote_sources, calendar_start, calendar_end, request).getEvents()
1.34 + events = getActiveRevisions(events)
1.35 all_shown_events = getEventsInPeriod(events, getCalendarPeriod(calendar_start, calendar_end))
1.36 earliest, latest = getEventLimits(all_shown_events)
1.37