pythoncaldavhorde

How to update event via Python's CalDav


I am using Python's library: CalDav in order to connect Horde Calendar.

I have no trouble with creating a new event, however, I can't find in the documentation method how to update existing event.


Solution

  • Assuming the library you are using is this one: https://pythonhosted.org/caldav/.

    To update an event you: - retrieve or create the event you want to modify - modify whatever you need to modify (but leave the UID unchanged) - call save()

    See below an example from the library's test (see https://pythonhosted.org/caldav/#more-examples) - it creates an event starting in 2016, changes it to start in 2017 and calls save() to update the event on the CalDAV server:

    def testDateSearchAndFreeBusy(self):
        [..]
        ## Create calendar, add event ...
        c = self.principal.make_calendar(name="Yep", cal_id=testcal_id)
        assert_not_equal(c.url, None)
    
        e = c.add_event(ev1)
        [..]
        ## ev2 is same UID, but one year ahead.
        # The timestamp should change.
        e.data = ev2
        e.save()