#158: Recurring events
- Contents
Make it possible to add an event that is recurring, meaning that it occurs more than once. This is currently not possible in Plone - the only way to do it is to duplicate the event by a copy-paste operation. We propose to implement recurring events within Plone.
- Proposed by
- Steve Haddox / Lennart Regebro
- Seconded by
- Nate Aune
- Proposal type
- User interface, Architecture
- State
- being-discussed
Definitions
- Recurring Event: An event that occurs more than once with the same details, time, location, etc and a consistent date (weekly, bi-weekly, monthly, annually).
- Recurring Event Object / Event Recur Portal Type: A single object within the portal that holds the information for the recurring event including possible end date, whether or not the event is infinite, and which dates the event has exceptions to its general metadata.
- Weekly: An event that occurs on the same day of each week
- Bi-Weekly: An event that occurs on the same day every other week
- Monthly: An event that occurs on the same day of a specific week of the month (first - fourth or last)
- Annually: An event that occurs once a year
Existing recurring events products:
- Recurring Event by Pawel Marzec
- Recurring Events by Steven Haddox
- CalCMF by Lennart Regebro
Motivation
This proposal exists as there is no implementation of recurring events within Plone that support global object creation, infinite date ranges, or installation without modification of core Plone system files. This proposal seeks to extend the Plone ATEvent schema and support Plone 3.0, and if possible 2.5.
Assumptions
User is willing to allow changes to logical code in default Plone calendar. Dependencies should rely only on the existing ATContentType for events and minimal Plone files should be modified.
Proposal
- Allow recurrence rules that support the iCalendar recurrence definition (except multiple times within one day).
- Ability to convert existing events to recurring events without recreation.
- The events recurrences must be indexed so they can be displayed in calendar views.
- The event portlet and event search page must treat recurrences as normal events.
Implementation
- Define a extension schema with archetypes.schemaextender that implements a recurrence schema.
- Use p4a.subtyper to enable/disable this extension on a per event basis.
- Calculate recurrences with dateutil.rrule.
- Provide adapters for folders and collections that provide an API to get events and occurrences.
- Index recurring dates as integers in a field index in portal_catalog.
- Deprecate portal_calendar
Details
This product will assume that the user wants to do as little as possible to add recurring events to their default Plone installation
It will provide an easily installable product that extends the existing event schemata on a per event-basis.
To get the extra fields needed for recurrence archetypes.schemaextender will define an extension schema with recurrence, that can extend any archetypes content type that provides event data.
Status:The product p4a.ploneevent has an implementation of this that is about 90% complete.
Any content type that implements basic event info (startdate and enddate) should be extensible with the recurrence schema. This can be done using p4a.subtyper.
Status:The product p4a.ploneevent has this implemented.
There needs to be a way to get the calculated recurrence dates from a content type that has recurrence info. An adapter that provides that method for any content type that implements the above extension schema will be provided.
Status:Not finished.
The most difficult part of a single-object implementation will be to implement the logic of recurring events being displayed into the portlet calendar and possibly other calendars such as Plone4ArtistsCalendar and CalendarX. To do this adapters will be provided that provide methods to get all occurrences of all events within the displayed time frame. These adapters will in turn work by doing catalog queries for events. Recurrences of the events will be handled by querying an index that keeps track of all days the event will recur. Multiple recurrences within one day will not be supported.
Status:50%. Eventproviders for Folders and Topics exist in the Dateable projects branch of p4a.plonecalendar, but they don't support recurrent events yet.
To be able to find recurrences matched on days the recurrences needs to be indexed. The simplest way to implement this is to index the days that the event recurs in a separate index. Other, more complex options, is to implement a dedicated recurrence index that does not store the calculated recurrences, but instead checks based on the recurrence data. This is more work and possibly slower, but handles infinitely recurring events better. A last option is that the index isn't in portal_catalog, but that self-contained indexes, possibly in portal_calendar, is used for this. This proposal suggest using the first, simplest option.
Status:
Not started.
Lastly, the plone portlet should be modified and possibly rewritten to use the eventproviders and thus support recurrence. plone_calendar should be deprecated.
Status:Not started, although Martin Aspeli has begun some sort of rewrite of the portlet that may be useful.
Deliverables
All functionality will in the first step be delivered as add-on products for Plone 3.0. Only when this is functionally complete and stable will it be added as default to Plone.
Risks
Modifications to default portlet calendar may be lost if this product is not integrated as a pre-installed product for Plone.
Progress log
Participants
Lennart Regebro
Steven Haddox?
Problems observed during implementing RecurringEvent product and few suggestions.
2. recurrence of last two days of month in 'monthly' mode: if we try to recue 31'th May when should we land? At 30'th June or at 1'st July? Escalated problems arrives near February.
3. leap year: February could have different length and the whole year also.
4. naive shifting 'datetime.now() + n' algorithm: becouse of point 2. and 3. We can not use it. Suggestion: n should be calculated in context of year and month pair.
5. quering catalog to build calendar view: in standard portal_calendar view we make maximum 31 queries but with CalendarX at multi-month view we could reach houndres of queries. Multiply it by 10 request/s and it will kill our sweet Plone even if we will have few, but recured during very long time period, events - every day for 2 years for example.
6. indexing recurring events: I've found and tried two paths, the dark and the light one. The dark path is to build indexes for fields which describes recurring attributes - we don't use much memory and catalog query is fast but when we want to query for events for 'thisDay' we have to filter all results and make acceptance test. Going this way I've visited the hell named 'objectify' and during acceptance test I've awaken RecurringEvent objects from ZODB to invoke method 'isRecueForDay(thisDay)' - simple hermetized and clear desing but naive. The light path was to index list of specially prepared numbers which represents number of day since epoch for every day for RecurringEvent when event appears. So quering for thisDay was very simple and very fast, but use more memory for indexes - but it was acceptable cost - imho.
7. separation of logic from content: it could be hard to play with RecurringEvent if the user have to know too much details about how to query for events in proper way. My suggestion is to build specialized tool for that with hermetized queries like: listEventsFor(thisDay) and isAnyEventFor(thisDay). These two methods would be enought to implement most of calendar's views.
8. iCal/vCal import/export: RFC2445 is the source. Not only for import/export but also for other things like attendees, recue exceptions and so on. There is also microlanguage for specifing recurrence modes, exceptions and much more. Maybe we should consider to implement attribute of type lines where per line we will have specified recurrence rule? And embed knowledge about it into portal tool?
9. attendees: even ATEvent have this field but do nothing with it, even doesn't use it in export iCal/vCal. We should use it becouse it is very important field and adds many features to Plone collective related aspects. We should be able to invite attendees to visit and import our instance of RecurringEvent - here appears the need for additional workflow. If the person we invite have e-mail she should be notified, if the person is member of our Plone portal maybe we should consider management of LocalRoles of our instace object ot give she ability to view private events.
Tommorow I'll write additional comments ;)
Regards
Pawel Marzec