| Home | Trees | Indices | Help |
|---|
|
|
1 ## 2 # Copyright (c) 2007-2016 Apple Inc. All rights reserved. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 ## 16 17 from caldavclientlibrary.protocol.webdav.requestresponse import RequestResponse 18 from caldavclientlibrary.protocol.caldav.definitions import methods 19 from StringIO import StringIO 20 from caldavclientlibrary.protocol.http.data.string import RequestDataString 21 from xml.etree.ElementTree import Element 22 from caldavclientlibrary.protocol.caldav.definitions import caldavxml 23 from xml.etree.ElementTree import SubElement 24 from caldavclientlibrary.protocol.webdav.definitions import davxml 25 from caldavclientlibrary.protocol.utils.xmlhelpers import BetterElementTree 26287730 super(MakeCalendar, self).__init__(session, methods.MKCALENDAR, url) 31 self.displayname = displayname 32 self.description = description 33 self.timezone = timezone 34 35 self.initRequestData()3638 if self.displayname or self.description or self.timezone: 39 # Write XML info to a string 40 os = StringIO() 41 self.generateXML(os) 42 self.request_data = RequestDataString(os.getvalue(), "text/xml charset=utf-8")4345 # Structure of document is: 46 # 47 # <CALDAV:mkcalendar> 48 # <DAV:prop> 49 # <<each property as elements>> 50 # </DAV:prop> 51 # </CALDAV:mkcalendar> 52 53 # <CALDAV:mkcalendar> element 54 mkcalendar = Element(caldavxml.mkcalendar) 55 56 # <DAV:prop> element 57 prop = SubElement(mkcalendar, davxml.prop) 58 59 # <DAV:displayname> element 60 if self.displayname: 61 displayname = SubElement(prop, davxml.displayname) 62 displayname.text = self.displayname 63 64 # <CalDAV:calendar-description> element 65 if self.description: 66 description = SubElement(prop, caldavxml.calendar_description) 67 description.text = self.description 68 69 # <CalDAV:timezone> element 70 if self.timezone: 71 timezone = SubElement(prop, caldavxml.calendar_timezone) 72 timezone.text = self.timezone 73 74 # Now we have the complete document, so write it out (no indentation) 75 xmldoc = BetterElementTree(mkcalendar) 76 xmldoc.writeUTF8(os)
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Thu Jul 7 15:01:49 2011 | http://epydoc.sourceforge.net |