calendaring_jmap.objects.calendar_object module#
JMAP calendar resource object.
Wraps a raw JSCalendar CalendarEvent dict with a minimal interface:
.id, .parent, get_data, get_icalendar_instance,
edit_icalendar_instance, and save.
- class calendaring_jmap.objects.calendar_object.JMAPCalendarObject(data, parent)[source]#
Bases:
objectThin wrapper around a raw JSCalendar CalendarEvent dict.
Stores the server's JSON response as-is. No JMAP field names are mapped to typed attributes: callers work with the dict directly via
get_data(), or convert to iCalendar viaget_icalendar_instance().- Variables:
data (
dict) – Raw JSCalendar CalendarEvent dict as returned byCalendarEvent/get.parent – The
JMAPCalendarthis object belongs to, orNonewhen fetched without a calendar context (e.g. viaget_event()).
- edit_icalendar_instance()[source]#
Borrow an editable
icalendar.Calendarfor this object.Yields the cached
icalendar.Calendarfor in-place editing. Callsave()after thewithblock to persist changes to the server.Note:
save()is sync-only. Async-backed calendars cannot use this path yet.Example:
with obj.edit_icalendar_instance() as cal: cal.subcomponents[0]["SUMMARY"] = vText("New title") obj.save()
- get_icalendar_instance()[source]#
Return an
icalendar.Calendarfor this object.The result is cached after the first conversion. Treat it as read-only; use
edit_icalendar_instance()to make and persist changes.- Return type:
- parent: JMAPCalendar | None#
- save()[source]#
Persist changes made via
edit_icalendar_instance()to the server.If
edit_icalendar_instance()was used, the (possibly edited) icalendar object is converted back to a JSCalendar dict first. If it wasn't,datais sent as-is, with no round trip through iCalendar.- Raises:
JMAPMethodError – If no parent calendar is set (
parentisNone).RuntimeError – If called on an async-backed calendar.
ValueError – If
edit_icalendar_instance()was used and the edit leaves the object missingUID/DTSTART, or withDTENDbeforeDTSTART; raised by the conversion back to JSCalendar, beforeupdate_eventis ever called.
- Return type: