[Calypso] VTODO not supported?

Petter Reinholdtsen pere at hungry.com
Mon Jan 25 04:02:59 PST 2016


[Jelmer Vernooij]
> That's odd. VTODO items work fine for me, I've been using them for a
> while with calypso.

Ah, good to know.  I was starting to wonder if vtodos could not be used
with calypso.

I've investigated some more, and the problem is really in the
import_file() function, which expect vcalendar blocks to have vevents,
which vtodos normally do not.  The reason is some strange code removing
duration added by Keith in commit
6e066c79de9c5100fb1306549d7c3f73dc711839 from 2013:

  Remove DURATION from events with both DTSTART and DURATION
    
  One of these two has to go as they may conflict.  I picked DURATION
  for no particular reason.

I do not understand the logic, but suspect this code should only trigger
when here are vevents to filter.  Why would dtstart and duration
conflict?  I could understand it if dtstart+dtend could conflict with
duration, but not dtstart alone.  Anyone know what is going on here?

Would something like this work?  It tries to modify only vevent objects
and reinsert it into the list after removing the duration value.  Not
sure if new_ics.add() will replace an existing object or not.  It work
with the tests I have written, but I do not have any vevent with both
dtstart and duration present. :)

diff --git a/calypso/webdav.py b/calypso/webdav.py
index 2d87349..b68c6a6 100644
--- a/calypso/webdav.py
+++ b/calypso/webdav.py
@@ -511,16 +511,17 @@ class Collection(object):
             new_object = vobject.readComponents(codecs.open(path,encoding='utf-8').read())
             for new_ics in new_object:
                 if new_ics.name == 'VCALENDAR':
-
-                    events = new_ics.vevent_list
-                    for ve in events:
-                        # Check for events with both dtstart and duration entries and
-                        # delete the duration one
-                        if ve.contents.has_key('dtstart') and ve.contents.has_key('duration'):
-                            del ve.contents['duration']
-                        new_ics.vevent_list = [ve]
-                        new_item = Item(new_ics.serialize().decode('utf-8'), None, path)
-                        self.import_item(new_item, path)
+                    if 'vevent' in new_ics.contents:
+                        # Check for events with both dtstart and
+                        # duration entries and delete the duration one
+                        for ve in new_ics.vevent_list:
+                            if ve.contents.has_key('dtstart') and ve.contents.has_key('duration'):
+                                del ve.contents['duration']
+                                # Replace old vevent with this modified one
+                                # FIXME verify that this really work.
+                                new_ics.add(ve)
+                    new_items = Item(new_ics.serialize().decode('utf-8'), None, path)
+                    self.import_item(new_items, path)
                 else:
                     new_item = Item(new_ics.serialize().decode('utf-8'), None, path)
                     self.import_item(new_item, path)

-- 
Happy hacking
Petter Reinholdtsen


More information about the Calypso mailing list