I created this too patches to make the carddav server sync with evolution.
Index: twistedcaldav/method/put.py =================================================================== --- twistedcaldav/method/put.py (revision 6337) +++ twistedcaldav/method/put.py (working copy) @@ -82,10 +82,9 @@ raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, str(e))) elif isAddressBookCollectionResource(parent): - # Content-type check content_type = request.headers.getHeader("content-type") - if content_type is not None and (content_type.mediaType, content_type.mediaSubtype) != ("text", "vcard"): + if content_type is not None and content_type.mediaType != "text" and content_type.mediaSubtype not in ["vcard", "x-vcard"]: log.err("MIME type %s not allowed in address book collection" % (content_type,)) raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "supported-address-data")))
Index: twistedcaldav/method/put_addressbook_common.py =================================================================== --- twistedcaldav/method/put_addressbook_common.py (revision 6337) +++ twistedcaldav/method/put_addressbook_common.py (working copy) @@ -41,7 +41,7 @@ from twistedcaldav.config import config from twistedcaldav.carddavxml import NoUIDConflict, carddav_namespace -from twistedcaldav.vcard import Component +from twistedcaldav.vcard import Component, Property as cProperty from twistedcaldav.vcardindex import ReservationError from twext.python.log import Logger @@ -174,8 +174,14 @@ else: try: if type(self.vcard) in (types.StringType, types.UnicodeType,): - self.vcarddata = self.vcard + self.vcard = Component.fromString(self.vcard) + if self.vcard.resourceUID() is None: + UID = self.destination.name().split('.')[0] + card_uid = cProperty("UID", UID) + self.vcard.addProperty(card_uid) + self.vcarddata = str(self.vcard) + except ValueError, e: log.err(str(e)) raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "valid-address-data"))) @@ -188,6 +194,7 @@ # Must have a valid UID at this point self.uid = self.vcard.resourceUID() + else: # Get UID from original resource self.source_index = self.sourceparent.index() @@ -370,6 +377,7 @@ if self.vcarddata is None: self.vcarddata = str(self.vcard) + md5 = MD5StreamWrapper(MemoryStream(self.vcarddata)) response = (yield self.destination.storeStream(md5))
_______________________________________________ calendarserver-dev mailing list calendarserver-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/calendarserver-dev