summaryrefslogtreecommitdiff
path: root/caldav/objects.py
diff options
context:
space:
mode:
authorTobias Brox <tobias@redpill-linpro.com>2022-01-07 21:33:22 +0100
committerTobias Brox <tobias@redpill-linpro.com>2022-01-07 21:33:22 +0100
commit67e47bce745813f1694ba755bf3b79fc8849a37e (patch)
treef2e96ae98d0f050efefb3add340ad65df679d820 /caldav/objects.py
parent509b4f01edab892c8581c5afac4378da46d822c4 (diff)
downloadpython-caldav-67e47bce745813f1694ba755bf3b79fc8849a37e.zip
bugfix: no_overwrite, no_create flags in save_todo would only work for events
Diffstat (limited to 'caldav/objects.py')
-rw-r--r--caldav/objects.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/caldav/objects.py b/caldav/objects.py
index 91f4af9..4032273 100644
--- a/caldav/objects.py
+++ b/caldav/objects.py
@@ -974,7 +974,7 @@ class Calendar(DAVObject):
except error.NotFoundError:
raise
except Exception as err:
- raise NotImplementedError("The object_by_uid is not compatible with some server implementations. work in progress.")
+ raise NotImplementedError(f"Server said {str(err)}. The object_by_uid is not compatible with some server implementations. work in progress.")
# Ref Lucas Verney, we've actually done a substring search, if the
# uid given in the query is short (i.e. just "0") we're likely to
@@ -1473,17 +1473,20 @@ class CalendarObjectResource(DAVObject):
## a unique new calendar item is created to the server without
## overwriting old stuff or vice versa - it seems silly to me
## to do a PUT instead of POST when creating new data).
+ ## TODO: the "find id"-logic is duplicated in _create,
+ ## should be refactored
if not self.id:
- try:
- self.id = self.vobject_instance.vevent.uid.value
- except AttributeError:
- pass
+ for component in self.vobject_instance.getChildren():
+ if hasattr(component, 'uid'):
+ self.id = component.uid.value
if not self.id and no_create:
raise error.ConsistencyError("no_create flag was set, but no ID given")
existing = None
## some servers require one to explicitly search for the right kind of object.
## todo: would arguably be nicer to verify the type of the object and take it from there
- if obj_type:
+ if not self.id:
+ methods = []
+ elif obj_type:
methods = (getattr(self.parent, "%s_by_uid" % obj_type),)
else:
methods = (self.parent.object_by_uid, self.parent.event_by_uid, self.parent.todo_by_uid, self.parent.journal_by_uid)