<!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>[13154] CalendarServer/branches/users/sagen/move2who-4</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/13154">13154</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2014-04-04 09:31:48 -0700 (Fri, 04 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>merge the two normalizationLookup implementations</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserssagenmove2who4calendarservertoolscalverifypy">CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/calverify.py</a></li>
<li><a href="#CalendarServerbranchesuserssagenmove2who4twistedcaldavdirectorytestaccountsxml">CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/test/accounts.xml</a></li>
<li><a href="#CalendarServerbranchesuserssagenmove2who4twistedcaldavresourcepy">CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/resource.py</a></li>
<li><a href="#CalendarServerbranchesuserssagenmove2who4twistedcaldavupgradepy">CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/upgrade.py</a></li>
<li><a href="#CalendarServerbranchesuserssagenmove2who4twistedcaldavutilpy">CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/util.py</a></li>
<li><a href="#CalendarServerbranchesuserssagenmove2who4txdavcaldavdatastoreutilpy">CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/util.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserssagenmove2who4calendarservertoolscalverifypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/calverify.py (13153 => 13154)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/calverify.py        2014-04-04 02:40:16 UTC (rev 13153)
+++ CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/calverify.py        2014-04-04 16:31:48 UTC (rev 13154)
</span><span class="lines">@@ -47,40 +47,38 @@
</span><span class="cx"> import traceback
</span><span class="cx"> import uuid
</span><span class="cx"> 
</span><del>-from pycalendar.icalendar import definitions
-from pycalendar.icalendar.calendar import Calendar
</del><ins>+from calendarserver.tools import tables
+from calendarserver.tools.cmdline import utilityMain, WorkerService
</ins><span class="cx"> from pycalendar.datetime import DateTime
</span><span class="cx"> from pycalendar.exceptions import ErrorBase
</span><ins>+from pycalendar.icalendar import definitions
+from pycalendar.icalendar.calendar import Calendar
</ins><span class="cx"> from pycalendar.period import Period
</span><span class="cx"> from pycalendar.timezone import Timezone
</span><del>-
</del><ins>+from twext.enterprise.dal.syntax import Select, Parameter, Count
+from twext.python.log import Logger
</ins><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="cx"> from twisted.python import usage
</span><span class="cx"> from twisted.python.usage import Options
</span><del>-
-from twext.python.log import Logger
-from twext.enterprise.dal.syntax import Select, Parameter, Count
-
</del><span class="cx"> from twistedcaldav.datafilters.peruserdata import PerUserDataFilter
</span><span class="cx"> from twistedcaldav.dateops import pyCalendarTodatetime
</span><del>-from twistedcaldav.ical import Component, ignoredComponents, \
</del><ins>+from twistedcaldav.ical import (
+    Component, ignoredComponents,
</ins><span class="cx">     InvalidICalendarDataError, Property, PERUSER_COMPONENT
</span><del>-from txdav.caldav.datastore.scheduling.itip import iTipGenerator
</del><ins>+)
</ins><span class="cx"> from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
</span><del>-from twistedcaldav.util import normalizationLookup
-
-from txdav.caldav.icalendarstore import ComponentUpdateState
</del><span class="cx"> from txdav.caldav.datastore.scheduling.icalsplitter import iCalSplitter
</span><span class="cx"> from txdav.caldav.datastore.scheduling.implicit import ImplicitScheduler
</span><ins>+from txdav.caldav.datastore.scheduling.itip import iTipGenerator
</ins><span class="cx"> from txdav.caldav.datastore.sql import CalendarStoreFeatures
</span><ins>+from txdav.caldav.datastore.util import normalizationLookup
+from txdav.caldav.icalendarstore import ComponentUpdateState
</ins><span class="cx"> from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
</span><span class="cx"> from txdav.common.icommondatastore import InternalDataStoreError
</span><span class="cx"> from txdav.who.idirectory import (
</span><span class="cx">     RecordType as CalRecordType, AutoScheduleMode
</span><span class="cx"> )
</span><del>-from calendarserver.tools.cmdline import utilityMain, WorkerService
</del><span class="cx"> 
</span><del>-from calendarserver.tools import tables
</del><span class="cx"> 
</span><span class="cx"> log = Logger()
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServerbranchesuserssagenmove2who4twistedcaldavdirectorytestaccountsxml"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/test/accounts.xml (13153 => 13154)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/test/accounts.xml        2014-04-04 02:40:16 UTC (rev 13153)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/test/accounts.xml        2014-04-04 16:31:48 UTC (rev 13154)
</span><span class="lines">@@ -285,17 +285,6 @@
</span><span class="cx">     &lt;member-uid&gt;__cdaboo1__&lt;/member-uid&gt;
</span><span class="cx">   &lt;/record&gt;
</span><span class="cx"> 
</span><del>-  &lt;!-- Repeat is not (yet?) supported in twext.who.xml
-  &lt;user repeat=&quot;100&quot;&gt;
-    &lt;short-name&gt;user%02d&lt;/short-name&gt;
-    &lt;uid&gt;user%02d&lt;/uid&gt;
-    &lt;password&gt;%02duser&lt;/password&gt;
-    &lt;full-name&gt;~35 User %02d&lt;/full-name&gt;
-    &lt;first-name&gt;~5&lt;/first-name&gt;
-    &lt;last-name&gt;~9 User %02d&lt;/last-name&gt;
-    &lt;email&gt;~10@example.com&lt;/email&gt;
-  &lt;/user&gt;
-  --&gt;
</del><span class="cx"> 
</span><span class="cx">   &lt;record type=&quot;group&quot;&gt;
</span><span class="cx">     &lt;short-name&gt;managers&lt;/short-name&gt;
</span></span></pre></div>
<a id="CalendarServerbranchesuserssagenmove2who4twistedcaldavresourcepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/resource.py (13153 => 13154)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/resource.py        2014-04-04 02:40:16 UTC (rev 13153)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/resource.py        2014-04-04 16:31:48 UTC (rev 13154)
</span><span class="lines">@@ -77,7 +77,7 @@
</span><span class="cx"> from twistedcaldav.linkresource import LinkResource
</span><span class="cx"> from calendarserver.push.notifier import getPubSubAPSConfiguration
</span><span class="cx"> from twistedcaldav.sharing import SharedResourceMixin, SharedHomeMixin
</span><del>-from twistedcaldav.util import normalizationLookup
</del><ins>+from txdav.caldav.datastore.util import normalizationLookup
</ins><span class="cx"> from twistedcaldav.vcard import Component as vComponent
</span><span class="cx"> 
</span><span class="cx"> from txdav.common.icommondatastore import InternalDataStoreError, \
</span><span class="lines">@@ -1064,7 +1064,6 @@
</span><span class="cx">         returnValue(PerUserDataFilter(accessUID).filter(caldata))
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    # MOVE2WHO returns Deferred
</del><span class="cx">     def iCalendarAddressDoNormalization(self, ical):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Normalize calendar user addresses in the supplied iCalendar object into their
</span><span class="lines">@@ -1072,9 +1071,12 @@
</span><span class="cx"> 
</span><span class="cx">         @param ical: calendar object to normalize.
</span><span class="cx">         @type ical: L{Component}
</span><ins>+        @return: L{Deferred}
</ins><span class="cx">         &quot;&quot;&quot;
</span><del>-        return ical.normalizeCalendarUserAddresses(normalizationLookup,
-            self.principalForCalendarUserAddress)
</del><ins>+        return ical.normalizeCalendarUserAddresses(
+            normalizationLookup,
+            self.record.service.recordWithCalendarUserAddress
+        )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span></span></pre></div>
<a id="CalendarServerbranchesuserssagenmove2who4twistedcaldavupgradepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/upgrade.py (13153 => 13154)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/upgrade.py        2014-04-04 02:40:16 UTC (rev 13153)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/upgrade.py        2014-04-04 16:31:48 UTC (rev 13154)
</span><span class="lines">@@ -43,7 +43,7 @@
</span><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><span class="cx"> from txdav.caldav.datastore.scheduling.scheduler import DirectScheduler
</span><del>-from twistedcaldav.util import normalizationLookup
</del><ins>+from txdav.caldav.datastore.util import normalizationLookup
</ins><span class="cx"> 
</span><span class="cx"> from twisted.internet.defer import (
</span><span class="cx">     inlineCallbacks, succeed, returnValue
</span></span></pre></div>
<a id="CalendarServerbranchesuserssagenmove2who4twistedcaldavutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/util.py (13153 => 13154)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/util.py        2014-04-04 02:40:16 UTC (rev 13153)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/util.py        2014-04-04 16:31:48 UTC (rev 13154)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx"> from hashlib import md5, sha1
</span><span class="cx"> 
</span><span class="cx"> from twisted.internet import ssl, reactor
</span><del>-from twisted.internet.defer import inlineCallbacks, returnValue
</del><ins>+# from twisted.internet.defer import inlineCallbacks, returnValue
</ins><span class="cx"> from twisted.web import client
</span><span class="cx"> from twisted.python import failure
</span><span class="cx"> from twext.python.log import Logger
</span><span class="lines">@@ -496,37 +496,39 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-@inlineCallbacks
-def normalizationLookup(cuaddr, principalFunction, config):
-    &quot;&quot;&quot;
-    Lookup function to be passed to ical.normalizeCalendarUserAddresses.
-    Returns a tuple of (Full name, guid, and calendar user address list)
-    for the given cuaddr.  The principalFunction is called to retrieve the
-    principal for the cuaddr.
-    &quot;&quot;&quot;
-    try:
-        record = yield principalFunction(cuaddr)
-    except Exception, e:
-        log.debug(&quot;Lookup of %s failed: %s&quot; % (cuaddr, e))
-        record = None
</del><ins>+# @inlineCallbacks
+# def normalizationLookup(cuaddr, recordFunction, config):
+#     &quot;&quot;&quot;
+#     Lookup function to be passed to ical.normalizeCalendarUserAddresses.
+#     Returns a tuple of (Full name C{str}, guid C{UUID}, and calendar user address list C{str})
+#     for the given cuaddr.  The recordFunction is called to retrieve the
+#     record for the cuaddr.
+#     &quot;&quot;&quot;
+#     try:
+#         record = yield recordFunction(cuaddr)
+#     except Exception, e:
+#         log.debug(&quot;Lookup of %s failed: %s&quot; % (cuaddr, e))
+#         record = None
</ins><span class="cx"> 
</span><del>-    if record is None:
-        returnValue((None, None, None))
-    else:
</del><ins>+#     if record is None:
+#         returnValue((None, None, None))
+#     else:
</ins><span class="cx"> 
</span><del>-        # RFC5545 syntax does not allow backslash escaping in
-        # parameter values. A double-quote is thus not allowed
-        # in a parameter value except as the start/end delimiters.
-        # Single quotes are allowed, so we convert any double-quotes
-        # to single-quotes.
-        fullName = record.displayName.replace('&quot;', &quot;'&quot;)
-        cuas = record.calendarUserAddresses
-        try:
-            guid = record.guid
-        except AttributeError:
-            guid = None
</del><ins>+#         # RFC5545 syntax does not allow backslash escaping in
+#         # parameter values. A double-quote is thus not allowed
+#         # in a parameter value except as the start/end delimiters.
+#         # Single quotes are allowed, so we convert any double-quotes
+#         # to single-quotes.
+#         fullName = record.displayName.replace('&quot;', &quot;'&quot;).encode(&quot;utf-8&quot;)
+#         cuas = set(
+#             [cua.encode(&quot;utf-8&quot;) for cua in record.calendarUserAddresses]
+#         )
+#         try:
+#             guid = record.guid
+#         except AttributeError:
+#             guid = None
</ins><span class="cx"> 
</span><del>-        returnValue((fullName, guid, cuas))
</del><ins>+#         returnValue((fullName, guid, cuas))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServerbranchesuserssagenmove2who4txdavcaldavdatastoreutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/util.py (13153 => 13154)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/util.py        2014-04-04 02:40:16 UTC (rev 13153)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/util.py        2014-04-04 16:31:48 UTC (rev 13154)
</span><span class="lines">@@ -104,7 +104,7 @@
</span><span class="cx"> def normalizationLookup(cuaddr, recordFunction, config):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Lookup function to be passed to ical.normalizeCalendarUserAddresses.
</span><del>-    Returns a tuple of (Full name, guid, and calendar user address list)
</del><ins>+    Returns a tuple of (Full name C{str}, guid C{UUID}, and calendar user address list C{str})
</ins><span class="cx">     for the given cuaddr.  The recordFunction is called to retrieve the
</span><span class="cx">     record for the cuaddr.
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="lines">@@ -117,25 +117,25 @@
</span><span class="cx">     if record is None:
</span><span class="cx">         returnValue((None, None, None))
</span><span class="cx">     else:
</span><ins>+
</ins><span class="cx">         # RFC5545 syntax does not allow backslash escaping in
</span><span class="cx">         # parameter values. A double-quote is thus not allowed
</span><span class="cx">         # in a parameter value except as the start/end delimiters.
</span><span class="cx">         # Single quotes are allowed, so we convert any double-quotes
</span><span class="cx">         # to single-quotes.
</span><ins>+        fullName = record.displayName.replace('&quot;', &quot;'&quot;).encode(&quot;utf-8&quot;)
+        cuas = set(
+            [cua.encode(&quot;utf-8&quot;) for cua in record.calendarUserAddresses]
+        )
</ins><span class="cx">         try:
</span><span class="cx">             guid = record.guid
</span><span class="cx">         except AttributeError:
</span><span class="cx">             guid = None
</span><del>-        returnValue(
-            (
-                record.displayName.replace('&quot;', &quot;'&quot;),
-                guid,
-                record.calendarUserAddresses,
-            )
-        )
</del><span class="cx"> 
</span><ins>+        returnValue((fullName, guid, cuas))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def dropboxIDFromCalendarObject(calendarObject):
</span><span class="cx">     &quot;&quot;&quot;
</span></span></pre>
</div>
</div>

</body>
</html>