Ticket #1104 (closed defect: invalid)

Opened 14 years ago

Last modified 14 years ago

getMainAttendee() can sometimes return None

Reported by: Brian Sutherland <jinty@…> Owned by: lregebro
Priority: P2 Milestone: CPS 3.4.0
Component: CalZope Version: TRUNK
Severity: minor Keywords:


Hoi regbro,

This one is a bit dicy, but imagine if you will, a calendar of rooms. Each room is an attendee and the id is stored in the location field. A vocabulary ensures that the user cannot add an event to room that is not a part of the calendar. Then it is quite a bad idea to set the organizer_id to a room as well, because the event shows up in two of the rooms calendars.

Index: Products/CalZope/browser/adding.py
--- Products/CalZope/browser/adding.py  (revision 29050)
+++ Products/CalZope/browser/adding.py  (working copy)
@@ -48,8 +48,15 @@
     cal = view.context.context.getCalendar()
     attendee = cal.getMainAttendee()
     # title and description will be set directly after add
-    event = attendee.createEvent(dtstart=dtstart, duration=duration,
-                                 allday=allday)
+    if attendee is not None:
+        event = attendee.createEvent(dtstart=dtstart, duration=duration,
+                                     allday=allday)
+    else:
+        # We have no attendee, so we create directly with storage manager
+        # and hope the attendee is added via a different method
+        event = cal.portal_calendar.storage_manager.createEvent(
+                unique_id = None, dtstart=dtstart, duration=duration,
+                                     allday=allday)
     # XXX acquisition context needed?
     return event.__of__(cal)

Change History

comment:1 Changed 14 years ago by fguillaume

  • Priority changed from P1 to P2
  • Milestone changed from CPS 3.2.5 to CPS 3.4.0

comment:2 Changed 14 years ago by lregebro

Basically, this method is only used when adding from the userinterface on a calendar. The calendar *has* to have a main attendee, so that you can figure out what calendar to add it too.

I agree that the organizer should probably in this case not be a calendar, but the user, the getCurrentUserAttendee. But we still need one attendee to add the event too (or it will appear in no calendars). So, in short, you can not create events in a calendar that has no main attendee.

Possibly getMainAttendee should never return None, and only be a part of a calendar extension, so that the add form only appears on calendars that have main attendees.

comment:3 Changed 14 years ago by fguillaume

  • Status changed from new to closed
  • Resolution set to invalid

Closed at reporter's request.

Note: See TracTickets for help on using tickets.