<!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>[11946] CalendarServer/branches/users/cdaboo/sharing-in-the-store</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/11946">11946</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2013-11-14 09:35:45 -0800 (Thu, 14 Nov 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Tweak new api to pass around dict's rather than JSON encoding. JSON is only done within the low-level store api now.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretwistedcaldavnotificationspy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/notifications.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretwistedcaldavsharingpy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/sharing.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretwistedcaldavstorebridgepy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/storebridge.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcaldavdatastoretestcommonpy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/caldav/datastore/test/common.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastorefilepy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/file.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresqlpy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemacurrentoracledialectsql">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current-oracle-dialect.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemacurrentsql">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_28_to_29sql">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_28_to_29.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_28_to_29sql">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_28_to_29.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoreupgradesqlupgradesnotification_upgrade_from_0_to_1py">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/notification_upgrade_from_0_to_1.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoreupgradesqlupgradestesttest_notification_upgrade_from_0_to_1py">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/test/test_notification_upgrade_from_0_to_1.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommoninotificationspy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/inotifications.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretwistedcaldavnotificationspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/notifications.py (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/notifications.py        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/notifications.py        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> 
</span><span class="cx"> from txdav.common.icommondatastore import SyncTokenValidException
</span><span class="cx"> 
</span><ins>+import json
</ins><span class="cx"> import os
</span><span class="cx"> import types
</span><span class="cx"> 
</span><span class="lines">@@ -92,17 +93,6 @@
</span><span class="cx">         return davxml.ResourceType.notification
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    @inlineCallbacks
-    def addNotification(self, request, uid, xmltype, xmldata):
-
-        # Write data to file
-        rname = uid + &quot;.xml&quot;
-        yield self._writeNotification(request, uid, rname, xmltype, xmldata)
-
-        # Update database
-        self.notificationsDB().addOrUpdateRecord(NotificationRecord(uid, rname, xmltype.name))
-
-
</del><span class="cx">     def getNotifictionMessages(self, request, componentType=None, returnLatestVersion=True):
</span><span class="cx">         return succeed([])
</span><span class="cx"> 
</span><span class="lines">@@ -144,10 +134,10 @@
</span><span class="cx"> 
</span><span class="cx"> class NotificationRecord(object):
</span><span class="cx"> 
</span><del>-    def __init__(self, uid, name, xmltype):
</del><ins>+    def __init__(self, uid, name, notificationtype):
</ins><span class="cx">         self.uid = uid
</span><span class="cx">         self.name = name
</span><del>-        self.xmltype = xmltype
</del><ins>+        self.notificationtype = notificationtype if isinstance(notificationtype, dict) else json.loads(notificationtype)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -184,7 +174,7 @@
</span><span class="cx"> 
</span><span class="cx">         self._db_execute(&quot;&quot;&quot;insert or replace into NOTIFICATIONS (UID, NAME, TYPE)
</span><span class="cx">             values (:1, :2, :3)
</span><del>-            &quot;&quot;&quot;, record.uid, record.name, record.xmltype,
</del><ins>+            &quot;&quot;&quot;, record.uid, record.name, json.dumps(record.notificationtype),
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         self._db_execute(
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretwistedcaldavsharingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/sharing.py (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/sharing.py        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/sharing.py        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -48,9 +48,7 @@
</span><span class="cx"> 
</span><span class="cx"> from pycalendar.datetime import DateTime
</span><span class="cx"> 
</span><del>-import json
</del><span class="cx"> 
</span><del>-
</del><span class="cx"> # FIXME: Get rid of these imports
</span><span class="cx"> from twistedcaldav.directory.util import TRANSACTION_KEY
</span><span class="cx"> # circular import
</span><span class="lines">@@ -735,11 +733,11 @@
</span><span class="cx">         state = notificationState if notificationState else invitation.status()
</span><span class="cx">         summary = invitation.summary() if displayName is None else displayName
</span><span class="cx"> 
</span><del>-        xmltype = {
</del><ins>+        notificationtype = {
</ins><span class="cx">             &quot;notification-type&quot;: &quot;invite-notification&quot;,
</span><span class="cx">             &quot;shared-type&quot;: self.sharedResourceType(),
</span><span class="cx">         }
</span><del>-        xmldata = {
</del><ins>+        notificationdata = {
</ins><span class="cx">             &quot;notification-type&quot;: &quot;invite-notification&quot;,
</span><span class="cx">             &quot;shared-type&quot;: self.sharedResourceType(),
</span><span class="cx">             &quot;dtstamp&quot;: DateTime.getNowUTC().getText(),
</span><span class="lines">@@ -752,13 +750,10 @@
</span><span class="cx">             &quot;summary&quot;: summary,
</span><span class="cx">         }
</span><span class="cx">         if self.isCalendarCollection():
</span><del>-            xmldata[&quot;supported-components&quot;] = self._newStoreObject.getSupportedComponents()
</del><ins>+            notificationdata[&quot;supported-components&quot;] = self._newStoreObject.getSupportedComponents()
</ins><span class="cx"> 
</span><del>-        xmltype = json.dumps(xmltype)
-        xmldata = json.dumps(xmldata)
-
</del><span class="cx">         # Add to collections
</span><del>-        yield notifications.writeNotificationObject(invitation.uid(), xmltype, xmldata)
</del><ins>+        yield notifications.writeNotificationObject(invitation.uid(), notificationtype, notificationdata)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -1348,11 +1343,11 @@
</span><span class="cx">         # Generate invite XML
</span><span class="cx">         notificationUID = &quot;%s-reply&quot; % (replytoUID,)
</span><span class="cx"> 
</span><del>-        xmltype = {
</del><ins>+        notificationtype = {
</ins><span class="cx">             &quot;notification-type&quot;: &quot;invite-reply&quot;,
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        xmldata = {
</del><ins>+        notificationdata = {
</ins><span class="cx">             &quot;notification-type&quot;: &quot;invite-reply&quot;,
</span><span class="cx">             &quot;shared-type&quot;: sharedResource.sharedResourceType(),
</span><span class="cx">             &quot;dtstamp&quot;: DateTime.getNowUTC().getText(),
</span><span class="lines">@@ -1364,11 +1359,8 @@
</span><span class="cx">             &quot;summary&quot;: displayname if displayname is not None else &quot;&quot;,
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        xmltype = json.dumps(xmltype)
-        xmldata = json.dumps(xmldata)
-
</del><span class="cx">         # Add to collections
</span><del>-        yield notifications.writeNotificationObject(notificationUID, xmltype, xmldata)
</del><ins>+        yield notifications.writeNotificationObject(notificationUID, notificationtype, notificationdata)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def _handleInviteReply(self, request, invitereplydoc):
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretwistedcaldavstorebridgepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/storebridge.py (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/storebridge.py        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/storebridge.py        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -86,7 +86,6 @@
</span><span class="cx"> import collections
</span><span class="cx"> from twistedcaldav.sharing import invitationBindStatusToXMLMap, \
</span><span class="cx">     invitationBindModeToXMLMap
</span><del>-import json
</del><span class="cx"> 
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> Wrappers to translate between the APIs in L{txdav.caldav.icalendarstore} and
</span><span class="lines">@@ -3669,13 +3668,6 @@
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def addNotification(self, request, uid, xmltype, xmldata):
-        return maybeDeferred(
-            self._newStoreNotifications.writeNotificationObject,
-            uid, xmltype, xmldata
-        )
-
-
</del><span class="cx">     def deleteNotification(self, request, record):
</span><span class="cx">         return maybeDeferred(
</span><span class="cx">             self._newStoreNotifications.removeNotificationObjectWithName,
</span><span class="lines">@@ -3720,8 +3712,7 @@
</span><span class="cx">             qname = prop.qname()
</span><span class="cx"> 
</span><span class="cx">         if qname == customxml.NotificationType.qname():
</span><del>-            jsontype = self._newStoreObject.xmlType()
-            jsontype = json.loads(jsontype)
</del><ins>+            jsontype = self._newStoreObject.notificationType()
</ins><span class="cx">             if jsontype[&quot;notification-type&quot;] == &quot;invite-notification&quot;:
</span><span class="cx">                 typeAttr = {&quot;shared-type&quot;: jsontype[&quot;shared-type&quot;]}
</span><span class="cx">                 xmltype = customxml.InviteNotification(**typeAttr)
</span><span class="lines">@@ -3745,8 +3736,7 @@
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def text(self, ignored=None):
</span><span class="cx">         assert ignored is None, &quot;This is a notification object, not a notification&quot;
</span><del>-        jsondata = (yield self._newStoreObject.xmldata())
-        jsondata = json.loads(jsondata)
</del><ins>+        jsondata = (yield self._newStoreObject.notificationData())
</ins><span class="cx">         if jsondata[&quot;notification-type&quot;] == &quot;invite-notification&quot;:
</span><span class="cx">             ownerPrincipal = self.principalForUID(jsondata[&quot;owner&quot;])
</span><span class="cx">             ownerCN = ownerPrincipal.displayName()
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcaldavdatastoretestcommonpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/caldav/datastore/test/common.py (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/caldav/datastore/test/common.py        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/caldav/datastore/test/common.py        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -377,8 +377,8 @@
</span><span class="cx">         notifications = yield txn.notificationsWithUID(&quot;home1&quot;)
</span><span class="cx">         yield notifications.writeNotificationObject(
</span><span class="cx">             &quot;abc&quot;,
</span><del>-            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
-            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;
</del><ins>+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
</ins><span class="cx">         )
</span><span class="cx">         notificationObject = yield notifications.notificationObjectWithUID(&quot;abc&quot;)
</span><span class="cx">         returnValue(notificationObject)
</span><span class="lines">@@ -402,9 +402,17 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         txn = self.transactionUnderTest()
</span><span class="cx">         coll = yield txn.notificationsWithUID(&quot;home1&quot;)
</span><del>-        yield coll.writeNotificationObject(&quot;1&quot;, &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;, &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;)
</del><ins>+        yield coll.writeNotificationObject(
+            &quot;1&quot;,
+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
+        )
</ins><span class="cx">         st = yield coll.syncToken()
</span><del>-        yield coll.writeNotificationObject(&quot;2&quot;, &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;, &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;)
</del><ins>+        yield coll.writeNotificationObject(
+            &quot;2&quot;,
+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
+        )
</ins><span class="cx">         rev = self.token2revision(st)
</span><span class="cx">         yield coll.removeNotificationObjectWithUID(&quot;1&quot;)
</span><span class="cx">         st2 = yield coll.syncToken()
</span><span class="lines">@@ -428,17 +436,17 @@
</span><span class="cx">         )
</span><span class="cx">         yield notifications.writeNotificationObject(
</span><span class="cx">             &quot;abc&quot;,
</span><del>-            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
-            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
</del><ins>+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
</ins><span class="cx">         )
</span><span class="cx">         yield notifications.writeNotificationObject(
</span><span class="cx">             &quot;abc&quot;,
</span><del>-            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
-            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;,\&quot;summary\&quot;:\&quot;a summary\&quot;}&quot;,
</del><ins>+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;,\&quot;summary\&quot;:\&quot;a summary\&quot;}&quot;),
</ins><span class="cx">         )
</span><span class="cx">         abc = yield notifications.notificationObjectWithUID(&quot;abc&quot;)
</span><span class="cx">         self.assertEquals(
</span><del>-            json.loads((yield abc.xmldata())),
</del><ins>+            (yield abc.notificationData()),
</ins><span class="cx">             json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;,\&quot;summary\&quot;:\&quot;a summary\&quot;}&quot;),
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -461,8 +469,8 @@
</span><span class="cx">         self.notifierFactory.reset()
</span><span class="cx">         yield notifications.writeNotificationObject(
</span><span class="cx">             &quot;abc&quot;,
</span><del>-            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
-            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
</del><ins>+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         # notify is called prior to commit
</span><span class="lines">@@ -505,13 +513,13 @@
</span><span class="cx">         )
</span><span class="cx">         yield notifications.writeNotificationObject(
</span><span class="cx">             &quot;abc&quot;,
</span><del>-            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
-            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
</del><ins>+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
</ins><span class="cx">         )
</span><span class="cx">         yield notifications.writeNotificationObject(
</span><span class="cx">             &quot;def&quot;,
</span><del>-            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
-            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;,\&quot;summary\&quot;:\&quot;a summary\&quot;}&quot;,
</del><ins>+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;),
+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;,\&quot;summary\&quot;:\&quot;a summary\&quot;}&quot;),
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         yield self.commit()
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastorefilepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/file.py (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/file.py        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/file.py        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx"> from errno import EEXIST, ENOENT
</span><span class="cx"> from zope.interface import implements, directlyProvides
</span><span class="cx"> 
</span><ins>+import json
</ins><span class="cx"> import uuid
</span><span class="cx"> from twistedcaldav.sql import AbstractSQLDatabase, db_prefix
</span><span class="cx"> import os
</span><span class="lines">@@ -1499,17 +1500,17 @@
</span><span class="cx">         return self.notificationObjectWithName(name)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def writeNotificationObject(self, uid, xmltype, xmldata):
</del><ins>+    def writeNotificationObject(self, uid, notificationtype, notificationdata):
</ins><span class="cx">         name = uid + &quot;.xml&quot;
</span><span class="cx">         if name.startswith(&quot;.&quot;):
</span><span class="cx">             raise ObjectResourceNameNotAllowedError(name)
</span><span class="cx"> 
</span><span class="cx">         objectResource = NotificationObject(name, self)
</span><del>-        objectResource.setData(uid, xmltype, xmldata)
</del><ins>+        objectResource.setData(uid, notificationtype, notificationdata)
</ins><span class="cx">         self._cachedObjectResources[name] = objectResource
</span><span class="cx"> 
</span><span class="cx">         # Update database
</span><del>-        self.retrieveOldIndex().addOrUpdateRecord(NotificationRecord(uid, name, xmltype))
</del><ins>+        self.retrieveOldIndex().addOrUpdateRecord(NotificationRecord(uid, name, notificationtype))
</ins><span class="cx"> 
</span><span class="cx">         self.notifyChanged()
</span><span class="cx"> 
</span><span class="lines">@@ -1572,15 +1573,16 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @writeOperation
</span><del>-    def setData(self, uid, xmltype, xmldata, inserting=False):
</del><ins>+    def setData(self, uid, notificationtype, notificationdata, inserting=False):
</ins><span class="cx"> 
</span><span class="cx">         rname = uid + &quot;.xml&quot;
</span><span class="cx">         self._parentCollection.retrieveOldIndex().addOrUpdateRecord(
</span><del>-            NotificationRecord(uid, rname, xmltype)
</del><ins>+            NotificationRecord(uid, rname, notificationtype)
</ins><span class="cx">         )
</span><span class="cx"> 
</span><del>-        self._xmldata = xmldata
-        md5 = hashlib.md5(xmldata).hexdigest()
</del><ins>+        self._notificationdata = notificationdata
+        notificationtext = json.dumps(self._notificationdata)
+        md5 = hashlib.md5(notificationtext).hexdigest()
</ins><span class="cx"> 
</span><span class="cx">         def do():
</span><span class="cx">             backup = None
</span><span class="lines">@@ -1591,7 +1593,7 @@
</span><span class="cx">             try:
</span><span class="cx">                 # FIXME: concurrency problem; if this write is interrupted
</span><span class="cx">                 # halfway through, the underlying file will be corrupt.
</span><del>-                fh.write(xmldata)
</del><ins>+                fh.write(notificationtext)
</ins><span class="cx">             finally:
</span><span class="cx">                 fh.close()
</span><span class="cx">             def undo():
</span><span class="lines">@@ -1610,7 +1612,7 @@
</span><span class="cx"> 
</span><span class="cx">         props = self.properties()
</span><span class="cx">         props[PropertyName(*GETContentType.qname())] = GETContentType.fromString(generateContentType(MimeType(&quot;text&quot;, &quot;xml&quot;, params={&quot;charset&quot;: &quot;utf-8&quot;})))
</span><del>-        props[PropertyName.fromElement(NotificationType)] = NotificationType(xmltype)
</del><ins>+        props[PropertyName.fromElement(NotificationType)] = NotificationType(json.dumps(notificationtype))
</ins><span class="cx">         props[PropertyName.fromElement(TwistedGETContentMD5)] = TwistedGETContentMD5.fromString(md5)
</span><span class="cx"> 
</span><span class="cx">         # FIXME: the property store's flush() method may already have been
</span><span class="lines">@@ -1620,11 +1622,11 @@
</span><span class="cx">         # manipulation methods won't work.
</span><span class="cx">         self._transaction.addOperation(self.properties().flush, &quot;post-update property flush&quot;)
</span><span class="cx"> 
</span><del>-    _xmldata = None
</del><ins>+    _notificationdata = None
</ins><span class="cx"> 
</span><del>-    def xmldata(self):
-        if self._xmldata is not None:
-            return self._xmldata
</del><ins>+    def notificationData(self):
+        if self._notificationdata is not None:
+            return self._notificationdata
</ins><span class="cx">         try:
</span><span class="cx">             fh = self._path.open()
</span><span class="cx">         except IOError, e:
</span><span class="lines">@@ -1638,14 +1640,14 @@
</span><span class="cx">         finally:
</span><span class="cx">             fh.close()
</span><span class="cx"> 
</span><del>-        return text
</del><ins>+        return json.loads(text)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def uid(self):
</span><span class="cx">         return self._uid
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def xmlType(self):
</del><ins>+    def notificationType(self):
</ins><span class="cx">         # NB This is the NotificationType property element
</span><span class="cx">         return self.properties()[PropertyName.fromElement(NotificationType)]
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql.py (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql.py        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql.py        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -77,6 +77,7 @@
</span><span class="cx"> 
</span><span class="cx"> from zope.interface import implements, directlyProvides
</span><span class="cx"> 
</span><ins>+import json
</ins><span class="cx"> import sys
</span><span class="cx"> import time
</span><span class="cx"> 
</span><span class="lines">@@ -4430,7 +4431,7 @@
</span><span class="cx">         self._size = None
</span><span class="cx">         self._created = None
</span><span class="cx">         self._modified = None
</span><del>-        self._objectText = None
</del><ins>+        self._notificationData = None
</ins><span class="cx"> 
</span><span class="cx">         self._locked = False
</span><span class="cx"> 
</span><span class="lines">@@ -4841,7 +4842,7 @@
</span><span class="cx">         self._size = None
</span><span class="cx">         self._created = None
</span><span class="cx">         self._modified = None
</span><del>-        self._objectText = None
</del><ins>+        self._notificationData = None
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def uid(self):
</span><span class="lines">@@ -4885,19 +4886,19 @@
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def _text(self):
</span><del>-        if self._objectText is None:
</del><ins>+        if self._notificationData is None:
</ins><span class="cx">             texts = (
</span><span class="cx">                 yield self._textByIDQuery.on(self._txn,
</span><span class="cx">                                              resourceID=self._resourceID)
</span><span class="cx">             )
</span><span class="cx">             if texts:
</span><span class="cx">                 text = texts[0][0]
</span><del>-                self._objectText = text
</del><ins>+                self._notificationData = text
</ins><span class="cx">                 returnValue(text)
</span><span class="cx">             else:
</span><span class="cx">                 raise ConcurrentModification()
</span><span class="cx">         else:
</span><del>-            returnValue(self._objectText)
</del><ins>+            returnValue(self._notificationData)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -5118,14 +5119,14 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def writeNotificationObject(self, uid, xmltype, xmldata):
</del><ins>+    def writeNotificationObject(self, uid, notificationtype, notificationdata):
</ins><span class="cx"> 
</span><span class="cx">         inserting = False
</span><span class="cx">         notificationObject = yield self.notificationObjectWithUID(uid)
</span><span class="cx">         if notificationObject is None:
</span><span class="cx">             notificationObject = NotificationObject(self, uid)
</span><span class="cx">             inserting = True
</span><del>-        yield notificationObject.setData(uid, xmltype, xmldata, inserting=inserting)
</del><ins>+        yield notificationObject.setData(uid, notificationtype, notificationdata, inserting=inserting)
</ins><span class="cx">         if inserting:
</span><span class="cx">             yield self._insertRevision(&quot;%s.xml&quot; % (uid,))
</span><span class="cx">         else:
</span><span class="lines">@@ -5298,8 +5299,8 @@
</span><span class="cx">         self._size = None
</span><span class="cx">         self._created = None
</span><span class="cx">         self._modified = None
</span><del>-        self._xmlType = None
-        self._objectText = None
</del><ins>+        self._notificationType = None
+        self._notificationData = None
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def __repr__(self):
</span><span class="lines">@@ -5314,7 +5315,7 @@
</span><span class="cx">         obj = cls._objectSchema
</span><span class="cx">         return Select(
</span><span class="cx">             [obj.RESOURCE_ID, obj.NOTIFICATION_UID, obj.MD5,
</span><del>-             Len(obj.XML_DATA), obj.XML_TYPE, obj.CREATED, obj.MODIFIED],
</del><ins>+             Len(obj.NOTIFICATION_DATA), obj.NOTIFICATION_TYPE, obj.CREATED, obj.MODIFIED],
</ins><span class="cx">             From=obj,
</span><span class="cx">             Where=(obj.NOTIFICATION_HOME_RESOURCE_ID == Parameter(&quot;homeID&quot;))
</span><span class="cx">         )
</span><span class="lines">@@ -5354,9 +5355,13 @@
</span><span class="cx">              child._uid,
</span><span class="cx">              child._md5,
</span><span class="cx">              child._size,
</span><del>-             child._xmlType,
</del><ins>+             child._notificationType,
</ins><span class="cx">              child._created,
</span><span class="cx">              child._modified,) = tuple(row)
</span><ins>+            try:
+                child._notificationType = json.loads(child._notificationType)
+            except ValueError:
+                pass
</ins><span class="cx">             child._loadPropertyStore(
</span><span class="cx">                 props=propertyStores.get(child._resourceID, None)
</span><span class="cx">             )
</span><span class="lines">@@ -5372,8 +5377,8 @@
</span><span class="cx">             [
</span><span class="cx">                 no.RESOURCE_ID,
</span><span class="cx">                 no.MD5,
</span><del>-                Len(no.XML_DATA),
-                no.XML_TYPE,
</del><ins>+                Len(no.NOTIFICATION_DATA),
+                no.NOTIFICATION_TYPE,
</ins><span class="cx">                 no.CREATED,
</span><span class="cx">                 no.MODIFIED
</span><span class="cx">             ],
</span><span class="lines">@@ -5398,9 +5403,13 @@
</span><span class="cx">             (self._resourceID,
</span><span class="cx">              self._md5,
</span><span class="cx">              self._size,
</span><del>-             self._xmlType,
</del><ins>+             self._notificationType,
</ins><span class="cx">              self._created,
</span><span class="cx">              self._modified,) = tuple(rows[0])
</span><ins>+            try:
+                self._notificationType = json.loads(self._notificationType)
+            except ValueError:
+                pass
</ins><span class="cx">             self._loadPropertyStore()
</span><span class="cx">             returnValue(self)
</span><span class="cx">         else:
</span><span class="lines">@@ -5451,8 +5460,8 @@
</span><span class="cx">             {
</span><span class="cx">                 no.NOTIFICATION_HOME_RESOURCE_ID: Parameter(&quot;homeID&quot;),
</span><span class="cx">                 no.NOTIFICATION_UID: Parameter(&quot;uid&quot;),
</span><del>-                no.XML_TYPE: Parameter(&quot;xmlType&quot;),
-                no.XML_DATA: Parameter(&quot;xmlData&quot;),
</del><ins>+                no.NOTIFICATION_TYPE: Parameter(&quot;notificationType&quot;),
+                no.NOTIFICATION_DATA: Parameter(&quot;notificationData&quot;),
</ins><span class="cx">                 no.MD5: Parameter(&quot;md5&quot;),
</span><span class="cx">             },
</span><span class="cx">             Return=[no.RESOURCE_ID, no.CREATED, no.MODIFIED]
</span><span class="lines">@@ -5464,8 +5473,8 @@
</span><span class="cx">         no = cls._objectSchema
</span><span class="cx">         return Update(
</span><span class="cx">             {
</span><del>-                no.XML_TYPE: Parameter(&quot;xmlType&quot;),
-                no.XML_DATA: Parameter(&quot;xmlData&quot;),
</del><ins>+                no.NOTIFICATION_TYPE: Parameter(&quot;notificationType&quot;),
+                no.NOTIFICATION_DATA: Parameter(&quot;notificationData&quot;),
</ins><span class="cx">                 no.MD5: Parameter(&quot;md5&quot;),
</span><span class="cx">             },
</span><span class="cx">             Where=(no.NOTIFICATION_HOME_RESOURCE_ID == Parameter(&quot;homeID&quot;)).And(
</span><span class="lines">@@ -5475,41 +5484,44 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def setData(self, uid, xmltype, xmldata, inserting=False):
</del><ins>+    def setData(self, uid, notificationtype, notificationdata, inserting=False):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Set the object resource data and update and cached metadata.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        self._xmlType = xmltype
-        self._md5 = hashlib.md5(xmldata).hexdigest()
-        self._size = len(xmldata)
</del><ins>+        notificationtext = json.dumps(notificationdata)
+        self._notificationType = notificationtype
+        self._md5 = hashlib.md5(notificationtext).hexdigest()
+        self._size = len(notificationtext)
</ins><span class="cx">         if inserting:
</span><span class="cx">             rows = yield self._newNotificationQuery.on(
</span><span class="cx">                 self._txn, homeID=self._home._resourceID, uid=uid,
</span><del>-                xmlType=self._xmlType, xmlData=xmldata, md5=self._md5
</del><ins>+                notificationType=json.dumps(self._notificationType), notificationData=notificationtext, md5=self._md5
</ins><span class="cx">             )
</span><span class="cx">             self._resourceID, self._created, self._modified = rows[0]
</span><span class="cx">             self._loadPropertyStore()
</span><span class="cx">         else:
</span><span class="cx">             rows = yield self._updateNotificationQuery.on(
</span><span class="cx">                 self._txn, homeID=self._home._resourceID, uid=uid,
</span><del>-                xmlType=self._xmlType, xmlData=xmldata, md5=self._md5
</del><ins>+                notificationType=json.dumps(self._notificationType), notificationData=notificationtext, md5=self._md5
</ins><span class="cx">             )
</span><span class="cx">             self._modified = rows[0][0]
</span><del>-        self._objectText = xmldata
</del><ins>+        self._notificationData = notificationdata
</ins><span class="cx"> 
</span><del>-    _xmlDataFromID = Select(
-        [_objectSchema.XML_DATA], From=_objectSchema,
</del><ins>+    _notificationDataFromID = Select(
+        [_objectSchema.NOTIFICATION_DATA], From=_objectSchema,
</ins><span class="cx">         Where=_objectSchema.RESOURCE_ID == Parameter(&quot;resourceID&quot;))
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def xmldata(self):
-        if self._objectText is None:
-            self._objectText = (
-                yield self._xmlDataFromID.on(
-                    self._txn, resourceID=self._resourceID))[0][0]
-        returnValue(self._objectText)
</del><ins>+    def notificationData(self):
+        if self._notificationData is None:
+            self._notificationData = (yield self._notificationDataFromID.on(self._txn, resourceID=self._resourceID))[0][0]
+            try:
+                self._notificationData = json.loads(self._notificationData)
+            except ValueError:
+                pass
+        returnValue(self._notificationData)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def contentType(self):
</span><span class="lines">@@ -5527,8 +5539,8 @@
</span><span class="cx">         return self._size
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def xmlType(self):
-        return self._xmlType
</del><ins>+    def notificationType(self):
+        return self._notificationType
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def created(self):
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemacurrentoracledialectsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current-oracle-dialect.sql (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx">     &quot;RESOURCE_ID&quot; integer primary key,
</span><span class="cx">     &quot;NOTIFICATION_HOME_RESOURCE_ID&quot; integer not null references NOTIFICATION_HOME,
</span><span class="cx">     &quot;NOTIFICATION_UID&quot; nvarchar2(255),
</span><del>-    &quot;XML_TYPE&quot; nvarchar2(255),
</del><ins>+    &quot;NOTIFICATION_TYPE&quot; nvarchar2(255),
</ins><span class="cx">     &quot;XML_DATA&quot; nclob,
</span><span class="cx">     &quot;MD5&quot; nchar(32),
</span><span class="cx">     &quot;CREATED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemacurrentsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current.sql (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current.sql        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current.sql        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -117,8 +117,8 @@
</span><span class="cx">   RESOURCE_ID                   integer      primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
</span><span class="cx">   NOTIFICATION_HOME_RESOURCE_ID integer      not null references NOTIFICATION_HOME,
</span><span class="cx">   NOTIFICATION_UID              varchar(255) not null,
</span><del>-  XML_TYPE                      varchar(255) not null,
-  XML_DATA                      text         not null,
</del><ins>+  NOTIFICATION_TYPE             varchar(255) not null,
+  NOTIFICATION_DATA             text         not null,
</ins><span class="cx">   MD5                           char(32)     not null,
</span><span class="cx">   CREATED                       timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
</span><span class="cx">   MODIFIED                      timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_28_to_29sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_28_to_29.sql (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_28_to_29.sql        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_28_to_29.sql        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -23,5 +23,10 @@
</span><span class="cx"> alter table NOTIFICATION_HOME
</span><span class="cx">  add (&quot;DATAVERSION&quot; integer default 0 not null);
</span><span class="cx"> 
</span><ins>+alter table NOTIFICATION
+  rename column XML_TYPE to NOTIFICATION_TYPE;
+alter table NOTIFICATION
+  rename column XML_DATA to NOTIFICATION_DATA;
+
</ins><span class="cx"> -- Now update the version
</span><span class="cx"> update CALENDARSERVER set VALUE = '29' where NAME = 'VERSION';
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_28_to_29sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_28_to_29.sql (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_28_to_29.sql        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_28_to_29.sql        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -23,5 +23,10 @@
</span><span class="cx"> alter table NOTIFICATION_HOME
</span><span class="cx">   add column DATAVERSION integer default 0 not null;
</span><span class="cx"> 
</span><ins>+alter table NOTIFICATION
+  rename column XML_TYPE to NOTIFICATION_TYPE;
+alter table NOTIFICATION
+  rename column XML_DATA to NOTIFICATION_DATA;
+
</ins><span class="cx"> -- Now update the version
</span><span class="cx"> update CALENDARSERVER set VALUE = '29' where NAME = 'VERSION';
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoreupgradesqlupgradesnotification_upgrade_from_0_to_1py"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/notification_upgrade_from_0_to_1.py (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/notification_upgrade_from_0_to_1.py        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/notification_upgrade_from_0_to_1.py        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -27,7 +27,6 @@
</span><span class="cx"> from txdav.xml.parser import WebDAVDocument
</span><span class="cx"> from twistedcaldav.sharing import invitationBindStatusFromXMLMap, \
</span><span class="cx">     invitationBindModeFromXMLMap
</span><del>-import json
</del><span class="cx"> 
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> Data upgrade from database version 0 to 1
</span><span class="lines">@@ -79,7 +78,7 @@
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">     # Convert the type value to JSON
</span><del>-    xmltype = WebDAVDocument.fromString(notification._xmlType).root_element
</del><ins>+    xmltype = WebDAVDocument.fromString(notification.notificationType()).root_element
</ins><span class="cx">     shared_type = &quot;calendar&quot;
</span><span class="cx">     if xmltype.children[0].qname() == customxml.InviteNotification.qname():
</span><span class="cx">         jsontype = {&quot;notification-type&quot;: &quot;invite-notification&quot;}
</span><span class="lines">@@ -90,7 +89,7 @@
</span><span class="cx">         jsontype = {&quot;notification-type&quot;: &quot;invite-reply&quot;}
</span><span class="cx"> 
</span><span class="cx">     # Convert the data value to JSON
</span><del>-    xmldata = (yield notification.xmldata())
</del><ins>+    xmldata = (yield notification.notificationData())
</ins><span class="cx">     xmldata = WebDAVDocument.fromString(xmldata).root_element
</span><span class="cx"> 
</span><span class="cx">     def _extract_UID(uri):
</span><span class="lines">@@ -163,6 +162,4 @@
</span><span class="cx">             &quot;summary&quot;: summary,
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-    jsontype = json.dumps(jsontype)
-    jsondata = json.dumps(jsondata)
</del><span class="cx">     yield notification.setData(notification.uid(), jsontype, jsondata)
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoreupgradesqlupgradestesttest_notification_upgrade_from_0_to_1py"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/test/test_notification_upgrade_from_0_to_1.py (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/test/test_notification_upgrade_from_0_to_1.py        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/test/test_notification_upgrade_from_0_to_1.py        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -23,8 +23,6 @@
</span><span class="cx">     _BIND_MODE_WRITE, _BIND_STATUS_ACCEPTED, _BIND_MODE_READ
</span><span class="cx"> from txdav.common.datastore.upgrade.sql.upgrades.notification_upgrade_from_0_to_1 import doUpgrade
</span><span class="cx"> 
</span><del>-import json
-
</del><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> Tests for L{txdav.common.datastore.upgrade.sql.upgrade}.
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="lines">@@ -170,9 +168,9 @@
</span><span class="cx">             ),
</span><span class="cx">         )
</span><span class="cx"> 
</span><del>-        for uid, xmltype, _ignore_jtype, xmldata, _ignore_jdata in data:
</del><ins>+        for uid, notificationtype, _ignore_jtype, notificationdata, _ignore_jdata in data:
</ins><span class="cx">             notifications = yield self.transactionUnderTest().notificationsWithUID(&quot;user01&quot;)
</span><del>-            yield notifications.writeNotificationObject(uid, xmltype, xmldata)
</del><ins>+            yield notifications.writeNotificationObject(uid, notificationtype, notificationdata)
</ins><span class="cx"> 
</span><span class="cx">         # Force data version to previous
</span><span class="cx">         nh = notifications._homeSchema
</span><span class="lines">@@ -188,9 +186,9 @@
</span><span class="cx">         version = (yield notifications.dataVersion())
</span><span class="cx">         self.assertEqual(version, 1)
</span><span class="cx"> 
</span><del>-        for uid, _ignore_xmltype, jtype, _ignore_xmldata, jdata in data:
</del><ins>+        for uid, _ignore_notificationtype, jtype, _ignore_notificationdata, jdata in data:
</ins><span class="cx">             notification = (yield notifications.notificationObjectWithUID(uid))
</span><span class="cx">             self.assertTrue(notification is not None, msg=&quot;Failed {uid}&quot;.format(uid=uid))
</span><del>-            self.assertEqual(json.loads(notification.xmlType()), jtype, msg=&quot;Failed {uid}&quot;.format(uid=uid))
-            data = (yield notification.xmldata())
-            self.assertEqual(json.loads(data), jdata, msg=&quot;Failed {uid}&quot;.format(uid=uid))
</del><ins>+            self.assertEqual(notification.notificationType(), jtype, msg=&quot;Failed {uid}&quot;.format(uid=uid))
+            data = (yield notification.notificationData())
+            self.assertEqual(data, jdata, msg=&quot;Failed {uid}&quot;.format(uid=uid))
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommoninotificationspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/inotifications.py (11945 => 11946)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/inotifications.py        2013-11-14 03:47:16 UTC (rev 11945)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/inotifications.py        2013-11-14 17:35:45 UTC (rev 11946)
</span><span class="lines">@@ -72,10 +72,10 @@
</span><span class="cx">             object exists.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-    def writeNotificationObject(uid, xmltype, xmldata): #@NoSelf
</del><ins>+    def writeNotificationObject(uid, notificationtype, notificationdata): #@NoSelf
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Write a notification with the given C{uid} in this notification
</span><del>-        collection from the given C{xmldata} with given C{xmltype}.  If a
</del><ins>+        collection from the given C{notificationdata} with given C{notificationtype}.  If a
</ins><span class="cx">         L{INotificationObject} with the same uid already exists in this
</span><span class="cx">         L{INotificationCollection}, it will be overwritten.
</span><span class="cx"> 
</span><span class="lines">@@ -83,18 +83,12 @@
</span><span class="cx">             written.
</span><span class="cx">         @type uid: C{str}
</span><span class="cx"> 
</span><del>-        @param xmltype: the node within the notification payload, emptied of
-            its children, to indicate the type of notification and fill out the
-            C{CS:notificationtype} property.
</del><ins>+        @param notificationtype: the type of notification as a C{dict}.
</ins><span class="cx"> 
</span><del>-        @type xmltype: an instance of
-            L{txdav.xml.base.WebDAVElement},
-            most likely a subclass like L{twistedcaldav.customxml.InviteReply},
-            L{twistedcaldav.customxml.InviteRemove}, etc.
</del><ins>+        @type notificationtype: C{dict}
</ins><span class="cx"> 
</span><del>-        @param xmldata: the serialized representation of the C{CS:notification}
-            node.
-        @type xmldata: C{str}
</del><ins>+        @param notificationdata: the representation of the notification data as a C{dict}.
+        @type notificationdata: C{dict}
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">     def removeNotificationObjectWithName(name): #@NoSelf
</span><span class="lines">@@ -142,23 +136,23 @@
</span><span class="cx">     An notification object describes an XML notification.
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-    def setData(uid, xmltype, xmldata, inserting=False): #@NoSelf
</del><ins>+    def setData(uid, notificationtype, notificationdata, inserting=False): #@NoSelf
</ins><span class="cx">         &quot;&quot;&quot;
</span><del>-        Rewrite this notification object to match the given C{xmltype} and
-        C{xmldata}. C{xmldata} must have the same UID as this notification object.
</del><ins>+        Rewrite this notification object to match the given C{notificationtype} and
+        C{notificationdata}. C{notificationdata} must have the same UID as this notification object.
</ins><span class="cx"> 
</span><del>-        @param xmltype: a string.
-        @param xmldata: a string.
</del><ins>+        @param notificationtype: a string.
+        @param notificationdata: a string.
</ins><span class="cx">         @raise InvalidObjectResourceError: if the given
</span><del>-            C{xmltype} or C{xmldata} is not a valid for
</del><ins>+            C{notificationtype} or C{notificationdata} is not a valid for
</ins><span class="cx">             an notification object.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-    def xmldata(): #@NoSelf
</del><ins>+    def notificationData(): #@NoSelf
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Retrieve the notification data for this notification object.
</span><span class="cx"> 
</span><del>-        @return: a string.
</del><ins>+        @return: a C{dict}.
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">     def uid(): #@NoSelf
</span></span></pre>
</div>
</div>

</body>
</html>