<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14076] CalendarServer/trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14076">14076</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-10-13 10:11:18 -0700 (Mon, 13 Oct 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Change augments conversion to only write out new file if there were changes. Also use the xmlutil apis so that proper XML file header is used.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkconfauthaugmentsdefaultxml">CalendarServer/trunk/conf/auth/augments-default.xml</a></li>
<li><a href="#CalendarServertrunkconfauthaugmentstestxml">CalendarServer/trunk/conf/auth/augments-test.xml</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtesttest_upgradepy">CalendarServer/trunk/twistedcaldav/test/test_upgrade.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavupgradepy">CalendarServer/trunk/twistedcaldav/upgrade.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkconfauthaugmentsdefaultxml"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/conf/auth/augments-default.xml (14075 => 14076)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/conf/auth/augments-default.xml        2014-10-13 14:57:29 UTC (rev 14075)
+++ CalendarServer/trunk/conf/auth/augments-default.xml        2014-10-13 17:11:18 UTC (rev 14076)
</span><span class="lines">@@ -1,5 +1,23 @@
</span><span class="cx"> <?xml version="1.0" encoding="utf-8"?>
</span><ins>+
+<!--
+Copyright (c) 2006-2014 Apple Inc. All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+ -->
+
</ins><span class="cx"> <!DOCTYPE augments SYSTEM "augments.dtd">
</span><ins>+
</ins><span class="cx"> <augments>
</span><span class="cx"> <record>
</span><span class="cx"> <uid>Default</uid>
</span></span></pre></div>
<a id="CalendarServertrunkconfauthaugmentstestxml"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/conf/auth/augments-test.xml (14075 => 14076)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/conf/auth/augments-test.xml        2014-10-13 14:57:29 UTC (rev 14075)
+++ CalendarServer/trunk/conf/auth/augments-test.xml        2014-10-13 17:11:18 UTC (rev 14076)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+Copyright (c) 2006-2014 Apple Inc. All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+ -->
+
+<!DOCTYPE augments SYSTEM "augments.dtd">
+
</ins><span class="cx"> <augments>
</span><span class="cx"> <record>
</span><span class="cx"> <uid>Default</uid>
</span><span class="lines">@@ -59,4 +79,4 @@
</span><span class="cx"> <auto-schedule-mode>decline-always</auto-schedule-mode>
</span><span class="cx"> <auto-accept-group>20000000-0000-0000-0000-000000000001</auto-accept-group>
</span><span class="cx"> </record>
</span><del>-</augments>
</del><span class="cx">\ No newline at end of file
</span><ins>+</augments>
</ins></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtesttest_upgradepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/test/test_upgrade.py (14075 => 14076)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/test/test_upgrade.py        2014-10-13 14:57:29 UTC (rev 14075)
+++ CalendarServer/trunk/twistedcaldav/test/test_upgrade.py        2014-10-13 17:11:18 UTC (rev 14076)
</span><span class="lines">@@ -1548,7 +1548,9 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-oldAugmentsFormat = """<augments>
</del><ins>+oldAugmentsFormat = """<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE augments SYSTEM "augments.dtd">
+<augments>
</ins><span class="cx"> <record>
</span><span class="cx"> <uid>9F3603DD-65D0-480D-A1D1-5D33CAC41A13</uid>
</span><span class="cx"> <enable>true</enable>
</span><span class="lines">@@ -1583,7 +1585,7 @@
</span><span class="cx"> <auto-schedule>false</auto-schedule>
</span><span class="cx"> <auto-schedule-mode>automatic</auto-schedule-mode>
</span><span class="cx"> </record>
</span><del>- <record>
</del><ins>+ <record>
</ins><span class="cx"> <uid>FC9A7F56-CCCA-4401-9160-903902880A37</uid>
</span><span class="cx"> <enable>false</enable>
</span><span class="cx"> <enable-calendar>true</enable-calendar>
</span><span class="lines">@@ -1595,9 +1597,48 @@
</span><span class="cx"> </augments>
</span><span class="cx"> """
</span><span class="cx">
</span><del>-newAugmentsFormat = """<augments>\n <record>\n <uid>9F3603DD-65D0-480D-A1D1-5D33CAC41A13</uid>\n <enable-calendar>true</enable-calendar>\n <enable-addressbook>true</enable-addressbook>\n <enable-login>true</enable-login>\n <auto-schedule-mode>none</auto-schedule-mode>\n </record>\n <record>\n <uid>6A49C436-4CDB-4184-AD87-6F945040E37A</uid>\n <enable-calendar>true</enable-calendar>\n <enable-addressbook>true</enable-addressbook>\n <enable-login>true</enable-login>\n </record>\n <record>\n <uid>60B771CC-D727-4453-ACE0-0FE13CD7445A</uid>\n <enable-calendar>true</enable-calendar>\n <enable-addressbook>true</enable-addressbook>\n <enable-login>true</enable-login>\n <auto-schedule-mode>none</auto-schedule-mod
e>\n </record>\n <record>\n <uid>E173AADC-4642-43CB-9745-8CE436A6FE4A</uid>\n <enable-calendar>true</enable-calendar>\n <enable-addressbook>true</enable-addressbook>\n <enable-login>true</enable-login>\n <auto-schedule-mode>none</auto-schedule-mode>\n </record>\n <record>\n <uid>FC9A7F56-CCCA-4401-9160-903902880A37</uid>\n <enable-calendar>true</enable-calendar>\n <enable-addressbook>true</enable-addressbook>\n <enable-login>true</enable-login>\n <auto-schedule-mode>accept-if-free</auto-schedule-mode>\n </record>\n</augments>"""
</del><ins>+newAugmentsFormat = """<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE augments SYSTEM "augments.dtd">
</ins><span class="cx">
</span><ins>+<augments>
+ <record>
+ <uid>9F3603DD-65D0-480D-A1D1-5D33CAC41A13</uid>
+ <enable-calendar>true</enable-calendar>
+ <enable-addressbook>true</enable-addressbook>
+ <enable-login>true</enable-login>
+ <auto-schedule-mode>none</auto-schedule-mode>
+ </record>
+ <record>
+ <uid>6A49C436-4CDB-4184-AD87-6F945040E37A</uid>
+ <enable-calendar>true</enable-calendar>
+ <enable-addressbook>true</enable-addressbook>
+ <enable-login>true</enable-login>
+ </record>
+ <record>
+ <uid>60B771CC-D727-4453-ACE0-0FE13CD7445A</uid>
+ <enable-calendar>true</enable-calendar>
+ <enable-addressbook>true</enable-addressbook>
+ <enable-login>true</enable-login>
+ <auto-schedule-mode>none</auto-schedule-mode>
+ </record>
+ <record>
+ <uid>E173AADC-4642-43CB-9745-8CE436A6FE4A</uid>
+ <enable-calendar>true</enable-calendar>
+ <enable-addressbook>true</enable-addressbook>
+ <enable-login>true</enable-login>
+ <auto-schedule-mode>none</auto-schedule-mode>
+ </record>
+ <record>
+ <uid>FC9A7F56-CCCA-4401-9160-903902880A37</uid>
+ <enable-calendar>true</enable-calendar>
+ <enable-addressbook>true</enable-addressbook>
+ <enable-login>true</enable-login>
+ <auto-schedule-mode>accept-if-free</auto-schedule-mode>
+ </record>
+</augments>
+"""
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> normalizeEvent = """BEGIN:VCALENDAR
</span><span class="cx"> VERSION:2.0
</span><span class="cx"> BEGIN:VEVENT
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavupgradepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/upgrade.py (14075 => 14076)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/upgrade.py        2014-10-13 14:57:29 UTC (rev 14075)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py        2014-10-13 17:11:18 UTC (rev 14076)
</span><span class="lines">@@ -36,19 +36,26 @@
</span><span class="cx"> tostring as etreeToString, Element as XMLElement
</span><span class="cx"> )
</span><span class="cx">
</span><del>-from twext.python.log import Logger
-from txdav.xml import element
</del><span class="cx"> from txweb2.dav.fileop import rmdir
</span><span class="cx">
</span><span class="cx"> from twistedcaldav import caldavxml
</span><ins>+from twistedcaldav.directory.calendaruserproxy import ProxySqliteDB
</ins><span class="cx"> from twistedcaldav.directory.calendaruserproxyloader import XMLCalendarUserProxyLoader
</span><span class="cx"> from twistedcaldav.directory.principal import DirectoryCalendarPrincipalResource
</span><span class="cx"> from twistedcaldav.directory.resourceinfo import ResourceInfoDatabase
</span><ins>+from twistedcaldav.directory.xmlaugmentsparser import ELEMENT_AUGMENTS
</ins><span class="cx"> from twistedcaldav.ical import Component
</span><ins>+from twistedcaldav.xmlutil import readXML, writeXML
+
+from txdav.caldav.datastore.index_file import db_basename
</ins><span class="cx"> from txdav.caldav.datastore.scheduling.cuaddress import LocalCalendarUser
</span><span class="cx"> from txdav.caldav.datastore.scheduling.imip.mailgateway import MailGatewayTokensDatabase
</span><ins>+from txdav.caldav.datastore.scheduling.imip.mailgateway import migrateTokensToStore
</ins><span class="cx"> from txdav.caldav.datastore.scheduling.scheduler import DirectScheduler
</span><span class="cx"> from txdav.caldav.datastore.util import normalizationLookup
</span><ins>+from txdav.who.delegates import addDelegate
+from txdav.who.idirectory import RecordType as CalRecordType
+from txdav.xml import element
</ins><span class="cx">
</span><span class="cx"> from twisted.internet.defer import (
</span><span class="cx"> inlineCallbacks, succeed, returnValue
</span><span class="lines">@@ -57,16 +64,10 @@
</span><span class="cx"> from twisted.python.reflect import namedAny
</span><span class="cx"> from twisted.python.reflect import namedClass
</span><span class="cx">
</span><del>-from txdav.caldav.datastore.index_file import db_basename
-
</del><span class="cx"> from calendarserver.tap.util import getRootResource, FakeRequest
</span><span class="cx">
</span><del>-from txdav.caldav.datastore.scheduling.imip.mailgateway import migrateTokensToStore
-
</del><ins>+from twext.python.log import Logger
</ins><span class="cx"> from twext.who.idirectory import RecordType
</span><del>-from txdav.who.idirectory import RecordType as CalRecordType
-from txdav.who.delegates import addDelegate
-from twistedcaldav.directory.calendaruserproxy import ProxySqliteDB
</del><span class="cx">
</span><span class="cx">
</span><span class="cx"> deadPropertyXattrPrefix = namedAny(
</span><span class="lines">@@ -715,24 +716,16 @@
</span><span class="cx"> @param augmentsFilePath: the file to convert
</span><span class="cx"> @type augmentsFilePath: L{FilePath}
</span><span class="cx"> """
</span><ins>+ # Read in XML
</ins><span class="cx"> try:
</span><del>- with augmentsFilePath.open() as fh:
- try:
- etree = parseXML(fh)
- except XMLParseError:
- log.error("Cannot parse {path}", path=augmentsFilePath.path)
- return
- except (OSError, IOError):
- # Can't read the file
- log.error("Cannot read {path}", path=augmentsFilePath.path)
</del><ins>+ _ignore_tree, augments_node = readXML(augmentsFilePath.path, ELEMENT_AUGMENTS)
+ except ValueError:
+ log.error("Cannot parse {path}", path=augmentsFilePath.path)
</ins><span class="cx"> return
</span><span class="cx">
</span><del>- augmentsNode = etree.getroot()
- if augmentsNode.tag != "augments":
- return
-
</del><span class="cx"> log.info("Converting augments.xml")
</span><del>- for recordNode in augmentsNode:
</del><ins>+ changed = False
+ for recordNode in augments_node:
</ins><span class="cx">
</span><span class="cx"> autoScheduleElement = recordNode.find("auto-schedule")
</span><span class="cx"> if autoScheduleElement is not None:
</span><span class="lines">@@ -741,12 +734,15 @@
</span><span class="cx"> if autoScheduleModeElement is not None:
</span><span class="cx"> autoScheduleModeElement.text = "none"
</span><span class="cx"> recordNode.remove(autoScheduleElement)
</span><ins>+ changed = True
</ins><span class="cx">
</span><span class="cx"> enableElement = recordNode.find("enable")
</span><span class="cx"> if enableElement is not None:
</span><span class="cx"> recordNode.remove(enableElement)
</span><ins>+ changed = True
</ins><span class="cx">
</span><del>- augmentsFilePath.setContent(etreeToString(augmentsNode, "utf-8"))
</del><ins>+ if changed:
+ writeXML(augmentsFilePath.path, augments_node)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> # The on-disk version number (which defaults to zero if .calendarserver_version
</span></span></pre>
</div>
</div>
</body>
</html>