views:

6

answers:

0

I am trying to query the Apple Calendarserver via the Python CalDAVClientLibrary. I can connect to the server, list the available calendars and read out the whole calendar, also I am able to store a new event.
For these operations, caldav uses the HTTP-Methods GET, PUT, REPORT and PROPFIND.

As an example (assuming there is at least one calendar)

Here is something I already found out to get started on the console:

import client.account
import protocol.caldav.multiget
from client.account import CalDAVAccount
from protocol.url import URL
import protocol.webdav.definitions.davxml as davxml
import xml
import uuid
from browser import utils

# principal-Parameter has to be a full URL
# Establish session to the caldav-server, with HTTP-logging enabled
myclient = client.account.CalDAVAccount(server="192.168.1.170", port=8008, user="MYUSER", pswd="password", principal="/principals/users/MYUSER/", logging=True)
print myclient
dir(myclient)

principal = myclient.principal
calendars = principal.listCalendars()
calendar = calendars[0]

# readData makes GET-requests. So the following line reads the whole calendar
data = calendar.session.readData(URL(calendar.path))

# This line reads a list of available properties
props = calendar.session.getProperties(URL(calendar.path),'',False)

# Read the etag of the calendar
myprops = calendar.session.getProperties(URL(calendar.path),(davxml.getetag,),False)
print calendar.description # Get the calendar's description
print calendar.displayname # Get the calendar's displayname
print myprops

But looking at the API-Documentation, which is in an HTML-Folder of the svn-checkout there is nothing set about doing search-queries and looking at the sourcecode there is also nothing. Several methods in there also prototypes. If I find out, how to deal with this, I will write a long article about it to help people getting started with CalDAV. At the moment it is quite hard to get information about this.