davobject – Base object definition#

class caldav.davobject.DAVObject(client=None, url=None, parent=None, id=None, props=None, name=None, **extra)[source][source]#

Base class for all DAV objects. Can be instantiated by a client and an absolute or relative URL, or from the parent object.

children(type=None)[source][source]#

List children, using a propfind (resourcetype) on the parent object, at depth = 1.

TODO: This is old code, it’s querying for DisplayName and ResourceTypes prop and returning a tuple of those. Those two are relatively arbitrary. I think it’s mostly only calendars having DisplayName, but it may make sense to ask for the children of a calendar also as an alternative way to get all events? It should be redone into a more generic method, and it should probably return a dict rather than a tuple. We should also look over to see if there is any code duplication.

Return type:

list[tuple[URL, Any, Any]]

delete()[source][source]#

Delete the object.

For sync clients, deletes and returns None. For async clients, returns a coroutine that must be awaited.

Return type:

None

Example (sync):

obj.delete()

Example (async):

await obj.delete()

get_display_name()[source][source]#

Get display name (calendar, principal, …more?)

get_properties(props=None, depth=0, parse_response_xml=True, parse_props=True)[source][source]#

Get properties (PROPFIND) for this object.

With parse_response_xml and parse_props set to True a best-attempt will be done on decoding the XML we get from the server - but this works only for properties that don’t have complex types. With parse_response_xml set to False, a DAVResponse object will be returned, and it’s up to the caller to decode. With parse_props set to false but parse_response_xml set to true, xml elements will be returned rather than values.

Parameters:

props[dav.ResourceType(), dav.DisplayName(), ...]

Returns:

{proptag: value, ...}

For async clients, returns a coroutine that must be awaited.

get_property(prop, use_cached=False, **passthrough)[source][source]#

Wrapper for the get_properties, when only one property is wanted

Parameters:
  • prop – the property to search for

  • use_cached – don’t send anything to the server if we’ve asked before

Other parameters are sent directly to the get_properties method

For async clients, returns a coroutine that must be awaited.

Return type:

str | None

property is_async_client: bool[source]#

Check if this object is connected to an async client.

Returns:

True if the client is an AsyncDAVClient, False otherwise.

property name: str | None[source]#

Display name of this DAV object.

Deprecated since version 3.0: Use get_display_name() instead.

save()[source][source]#

Save the object. This is an abstract method, that all classes derived from DAVObject implement.

Return type:

Self

Returns:

  • self

set_properties(props=None)[source][source]#

Set properties (PROPPATCH) for this object.

  • props = [dav.DisplayName(‘name’), …]

For async clients, returns a coroutine that must be awaited.

Returns:

  • self

Return type:

Self

caldav.davobject.log = <Logger caldav (WARNING)>[source][source]#

This file contains one class, the DAVObject which is the base class for Calendar, Principal, CalendarObjectResource (Event) and many others. There is some code here for handling some of the DAV-related communication, and the class lists some common methods that are shared on all kind of objects. Library users should not need to know a lot about the DAVObject class, should never need to initialize one, but may encounter inheritated methods coming from this class.