mirror of
https://github.com/Kozea/Radicale.git
synced 2025-06-26 16:45:52 +00:00
Default implementation for BaseCollection.serialize
This commit is contained in:
parent
47d311b101
commit
dbd06a1952
1 changed files with 10 additions and 1 deletions
|
@ -504,7 +504,16 @@ class BaseCollection:
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
"""Get the unicode string representing the whole collection."""
|
"""Get the unicode string representing the whole collection."""
|
||||||
raise NotImplementedError
|
if self.get_meta("tag") == "VCALENDAR":
|
||||||
|
collection = vobject.iCalendar()
|
||||||
|
for item in self.get_all():
|
||||||
|
for content in ("vevent", "vtodo", "vjournal"):
|
||||||
|
for component in getattr(item, "%s_list" % content, ()):
|
||||||
|
collection.add(component)
|
||||||
|
return collection.serialize()
|
||||||
|
elif self.get_meta("tag") == "VADDRESSBOOK":
|
||||||
|
return "".join(item.serialize() for item in self.get_all())
|
||||||
|
return ""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue