<!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>[14307] 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/14307">14307</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2015-01-15 10:11:02 -0800 (Thu, 15 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix and simplify cross-pod requests.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkrequirementsdevtxt">CalendarServer/trunk/requirements-dev.txt</a></li>
<li><a href="#CalendarServertrunktwistedcaldavstorebridgepy">CalendarServer/trunk/twistedcaldav/storebridge.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingischeduleschedulerpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/scheduler.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavicalendarstorepy">CalendarServer/trunk/txdav/caldav/icalendarstore.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingattachmentspy">CalendarServer/trunk/txdav/common/datastore/podding/attachments.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingconduitpy">CalendarServer/trunk/txdav/common/datastore/podding/conduit.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingdirectorypy">CalendarServer/trunk/txdav/common/datastore/podding/directory.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingrequestpy">CalendarServer/trunk/txdav/common/datastore/podding/request.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingresourcepy">CalendarServer/trunk/txdav/common/datastore/podding/resource.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingsharing_basepy">CalendarServer/trunk/txdav/common/datastore/podding/sharing_base.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingsharing_invitespy">CalendarServer/trunk/txdav/common/datastore/podding/sharing_invites.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingsharing_storepy">CalendarServer/trunk/txdav/common/datastore/podding/sharing_store.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingtesttest_conduitpy">CalendarServer/trunk/txdav/common/datastore/podding/test/test_conduit.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingtesttest_resourcepy">CalendarServer/trunk/txdav/common/datastore/podding/test/test_resource.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingtestutilpy">CalendarServer/trunk/txdav/common/datastore/podding/test/util.py</a></li>
<li><a href="#CalendarServertrunktxdavwhocachepy">CalendarServer/trunk/txdav/who/cache.py</a></li>
<li><a href="#CalendarServertrunktxdavwhodelegatespy">CalendarServer/trunk/txdav/who/delegates.py</a></li>
<li><a href="#CalendarServertrunktxdavwhodirectorypy">CalendarServer/trunk/txdav/who/directory.py</a></li>
<li><a href="#CalendarServertrunktxdavwhogroupspy">CalendarServer/trunk/txdav/who/groups.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkrequirementsdevtxt"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/requirements-dev.txt (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/requirements-dev.txt        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/requirements-dev.txt        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -8,4 +8,4 @@
</span><span class="cx"> q
</span><span class="cx"> tl.eggdeps
</span><span class="cx"> --editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVClientLibrary/trunk@13420#egg=CalDAVClientLibrary
</span><del>---editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@14300#egg=CalDAVTester
</del><ins>+--editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@14306#egg=CalDAVTester
</ins></span></pre></div>
<a id="CalendarServertrunktwistedcaldavstorebridgepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/storebridge.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/storebridge.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -2850,7 +2850,7 @@
</span><span class="cx"> 
</span><span class="cx">             # Look for client fixes
</span><span class="cx">             ua = request.headers.getHeader(&quot;User-Agent&quot;)
</span><del>-            client_fix_transp = matchClientFixes(config, ua)
</del><ins>+            client_fix_transp = &quot;ForceAttendeeTRANSP&quot; in matchClientFixes(config, ua)
</ins><span class="cx"> 
</span><span class="cx">             # Setup options
</span><span class="cx">             options = {
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingischeduleschedulerpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/scheduler.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/scheduler.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/scheduler.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -376,7 +376,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Check against this server.
</span><span class="cx">         matched = False
</span><del>-        serversDB = self.txn._store.directoryService().serversDB
</del><ins>+        serversDB = self.txn._store.directoryService().serversDB()
</ins><span class="cx">         if serversDB.getThisServer().checkThisIP(clientip):
</span><span class="cx">             matched = True
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavicalendarstorepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/icalendarstore.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/icalendarstore.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/caldav/icalendarstore.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -953,7 +953,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-class SetComponentOptions(Names):
</del><ins>+class SetComponentOptions(object):
</ins><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Constants for keys used in the L{ICalendarObject.setComponent} method's
</span><span class="cx">     C{options} dict. The definitions below define the constant key name and
</span><span class="lines">@@ -966,14 +966,18 @@
</span><span class="cx">         Value: L{bool}
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-    smartMerge = NamedConstant()
-    smartMerge.description = u&quot;Smart Merge: CalDAV If-Schedule-Tag-Match behavior&quot;
-    smartMerge.defaultValue = False
</del><ins>+    # Smart Merge: CalDAV If-Schedule-Tag-Match behavior
+    smartMerge = &quot;smartMerge&quot;
</ins><span class="cx"> 
</span><del>-    clientFixTRANSP = NamedConstant()
-    clientFixTRANSP.description = u&quot;Fix for clients not setting TRANSP&quot;
-    clientFixTRANSP.defaultValue = False
</del><ins>+    # Fix for clients not setting TRANSP
+    clientFixTRANSP = &quot;clientFixTRANSP&quot;
</ins><span class="cx"> 
</span><ins>+    _defaults = {
+        smartMerge: False,
+        clientFixTRANSP: False
+    }
+
</ins><span class="cx">     @staticmethod
</span><span class="cx">     def value(options, key):
</span><del>-        return options.get(key, key.defaultValue) if options is not None else key.defaultValue
</del><ins>+        defaultValue = SetComponentOptions._defaults.get(key)
+        return options.get(key, defaultValue) if options is not None else defaultValue
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingattachmentspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/attachments.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/attachments.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/common/datastore/podding/attachments.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -15,7 +15,6 @@
</span><span class="cx"> ##
</span><span class="cx"> 
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><del>-from twisted.python.reflect import namedClass
</del><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> class AttachmentsPoddingConduitMixin(object):
</span><span class="lines">@@ -48,13 +47,9 @@
</span><span class="cx">         request[&quot;filename&quot;] = filename
</span><span class="cx"> 
</span><span class="cx">         response = yield self.sendRequest(shareeView._txn, recipient, request, stream, content_type)
</span><ins>+        returnValue(response)
</ins><span class="cx"> 
</span><del>-        if response[&quot;result&quot;] == &quot;ok&quot;:
-            returnValue(response[&quot;value&quot;])
-        elif response[&quot;result&quot;] == &quot;exception&quot;:
-            raise namedClass(response[&quot;class&quot;])(response[&quot;result&quot;])
</del><span class="cx"> 
</span><del>-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def recv_add_attachment(self, txn, request):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -64,26 +59,15 @@
</span><span class="cx">         @type request: C{dict}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        actionName = &quot;add-attachment&quot;
-        _ignore_shareeView, objectResource = yield self._getResourcesForRequest(txn, request, actionName)
-        try:
-            attachment, location = yield objectResource.addAttachment(
-                request[&quot;rids&quot;],
-                request[&quot;streamType&quot;],
-                request[&quot;filename&quot;],
-                request[&quot;stream&quot;],
-            )
-        except Exception as e:
-            returnValue({
-                &quot;result&quot;: &quot;exception&quot;,
-                &quot;class&quot;: &quot;.&quot;.join((e.__class__.__module__, e.__class__.__name__,)),
-                &quot;request&quot;: str(e),
-            })
</del><ins>+        _ignore_shareeView, objectResource = yield self._getResourcesForRequest(txn, request)
+        attachment, location = yield objectResource.addAttachment(
+            request[&quot;rids&quot;],
+            request[&quot;streamType&quot;],
+            request[&quot;filename&quot;],
+            request[&quot;stream&quot;],
+        )
</ins><span class="cx"> 
</span><del>-        returnValue({
-            &quot;result&quot;: &quot;ok&quot;,
-            &quot;value&quot;: (attachment.managedID(), location,),
-        })
</del><ins>+        returnValue((attachment.managedID(), location,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -110,13 +94,9 @@
</span><span class="cx">         request[&quot;filename&quot;] = filename
</span><span class="cx"> 
</span><span class="cx">         response = yield self.sendRequest(shareeView._txn, recipient, request, stream, content_type)
</span><ins>+        returnValue(response)
</ins><span class="cx"> 
</span><del>-        if response[&quot;result&quot;] == &quot;ok&quot;:
-            returnValue(response[&quot;value&quot;])
-        elif response[&quot;result&quot;] == &quot;exception&quot;:
-            raise namedClass(response[&quot;class&quot;])(response[&quot;result&quot;])
</del><span class="cx"> 
</span><del>-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def recv_update_attachment(self, txn, request):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -126,26 +106,15 @@
</span><span class="cx">         @type request: C{dict}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        actionName = &quot;update-attachment&quot;
-        _ignore_shareeView, objectResource = yield self._getResourcesForRequest(txn, request, actionName)
-        try:
-            attachment, location = yield objectResource.updateAttachment(
-                request[&quot;managedID&quot;],
-                request[&quot;streamType&quot;],
-                request[&quot;filename&quot;],
-                request[&quot;stream&quot;],
-            )
-        except Exception as e:
-            returnValue({
-                &quot;result&quot;: &quot;exception&quot;,
-                &quot;class&quot;: &quot;.&quot;.join((e.__class__.__module__, e.__class__.__name__,)),
-                &quot;request&quot;: str(e),
-            })
</del><ins>+        _ignore_shareeView, objectResource = yield self._getResourcesForRequest(txn, request)
+        attachment, location = yield objectResource.updateAttachment(
+            request[&quot;managedID&quot;],
+            request[&quot;streamType&quot;],
+            request[&quot;filename&quot;],
+            request[&quot;stream&quot;],
+        )
</ins><span class="cx"> 
</span><del>-        returnValue({
-            &quot;result&quot;: &quot;ok&quot;,
-            &quot;value&quot;: (attachment.managedID(), location,),
-        })
</del><ins>+        returnValue((attachment.managedID(), location,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -167,14 +136,9 @@
</span><span class="cx">         request[&quot;rids&quot;] = rids
</span><span class="cx">         request[&quot;managedID&quot;] = managed_id
</span><span class="cx"> 
</span><del>-        response = yield self.sendRequest(shareeView._txn, recipient, request)
</del><ins>+        yield self.sendRequest(shareeView._txn, recipient, request)
</ins><span class="cx"> 
</span><del>-        if response[&quot;result&quot;] == &quot;ok&quot;:
-            returnValue(response[&quot;value&quot;])
-        elif response[&quot;result&quot;] == &quot;exception&quot;:
-            raise namedClass(response[&quot;class&quot;])(response[&quot;result&quot;])
</del><span class="cx"> 
</span><del>-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def recv_remove_attachment(self, txn, request):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -184,21 +148,8 @@
</span><span class="cx">         @type request: C{dict}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        actionName = &quot;remove-attachment&quot;
-        _ignore_shareeView, objectResource = yield self._getResourcesForRequest(txn, request, actionName)
-        try:
-            yield objectResource.removeAttachment(
-                request[&quot;rids&quot;],
-                request[&quot;managedID&quot;],
-            )
-        except Exception as e:
-            returnValue({
-                &quot;result&quot;: &quot;exception&quot;,
-                &quot;class&quot;: &quot;.&quot;.join((e.__class__.__module__, e.__class__.__name__,)),
-                &quot;request&quot;: str(e),
-            })
-
-        returnValue({
-            &quot;result&quot;: &quot;ok&quot;,
-            &quot;value&quot;: None,
-        })
</del><ins>+        _ignore_shareeView, objectResource = yield self._getResourcesForRequest(txn, request)
+        yield objectResource.removeAttachment(
+            request[&quot;rids&quot;],
+            request[&quot;managedID&quot;],
+        )
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingconduitpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/conduit.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/conduit.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/common/datastore/podding/conduit.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -16,8 +16,6 @@
</span><span class="cx"> 
</span><span class="cx"> from twext.python.log import Logger
</span><span class="cx"> 
</span><del>-from twisted.internet.defer import inlineCallbacks, returnValue
-
</del><span class="cx"> from txdav.common.idirectoryservice import DirectoryRecordNotFoundError
</span><span class="cx"> from txdav.common.datastore.podding.attachments import AttachmentsPoddingConduitMixin
</span><span class="cx"> from txdav.common.datastore.podding.base import FailedCrossPodRequestError
</span><span class="lines">@@ -26,7 +24,11 @@
</span><span class="cx"> from txdav.common.datastore.podding.sharing_invites import SharingInvitesPoddingConduitMixin
</span><span class="cx"> from txdav.common.datastore.podding.sharing_store import SharingStorePoddingConduitMixin
</span><span class="cx"> 
</span><ins>+from twisted.internet.defer import inlineCallbacks, returnValue
+from twisted.python.reflect import namedClass
+from twisted.python.failure import Failure
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx"> log = Logger()
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -114,7 +116,12 @@
</span><span class="cx">             response = (yield request.doRequest(txn))
</span><span class="cx">         except Exception as e:
</span><span class="cx">             raise FailedCrossPodRequestError(&quot;Failed cross-pod request: {}&quot;.format(e))
</span><del>-        returnValue(response)
</del><ins>+        if response[&quot;result&quot;] == &quot;exception&quot;:
+            raise namedClass(response[&quot;class&quot;])(response[&quot;result&quot;])
+        elif response[&quot;result&quot;] != &quot;ok&quot;:
+            raise FailedCrossPodRequestError(&quot;Cross-pod request failed: {}&quot;.format(response))
+        else:
+            returnValue(response.get(&quot;value&quot;))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -146,11 +153,15 @@
</span><span class="cx"> 
</span><span class="cx">         # Do the actual request processing
</span><span class="cx">         try:
</span><del>-            result = (yield getattr(self, method)(txn, data))
</del><ins>+            value = (yield getattr(self, method)(txn, data))
+            result = {&quot;result&quot;: &quot;ok&quot;}
+            if value is not None:
+                result[&quot;value&quot;] = value
</ins><span class="cx">         except Exception as e:
</span><ins>+            ex = Failure()
</ins><span class="cx">             yield txn.abort()
</span><span class="cx">             log.error(&quot;Failed action: {action}, {ex}&quot;, action=action, ex=e)
</span><del>-            raise FailedCrossPodRequestError(&quot;Failed action: {}, {}&quot;.format(action, e))
</del><ins>+            ex.raiseException()
</ins><span class="cx"> 
</span><span class="cx">         yield txn.commit()
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingdirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/directory.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/directory.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/common/datastore/podding/directory.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -15,7 +15,6 @@
</span><span class="cx"> ##
</span><span class="cx"> 
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><del>-from twisted.python.reflect import namedClass
</del><span class="cx"> from txdav.common.datastore.podding.base import FailedCrossPodRequestError
</span><span class="cx"> from txdav.who.delegates import Delegates
</span><span class="cx"> 
</span><span class="lines">@@ -41,13 +40,9 @@
</span><span class="cx">             &quot;action&quot;: &quot;all-group-delegates&quot;,
</span><span class="cx">         }
</span><span class="cx">         response = yield self.sendRequestToServer(txn, server, request)
</span><ins>+        returnValue(set(response))
</ins><span class="cx"> 
</span><del>-        if response[&quot;result&quot;] == &quot;ok&quot;:
-            returnValue(set(response[&quot;value&quot;]))
-        elif response[&quot;result&quot;] == &quot;exception&quot;:
-            raise namedClass(response[&quot;class&quot;])(response[&quot;result&quot;])
</del><span class="cx"> 
</span><del>-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def recv_all_group_delegates(self, txn, request):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -57,24 +52,11 @@
</span><span class="cx">         @type request: C{dict}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        if request[&quot;action&quot;] != &quot;all-group-delegates&quot;:
-            raise FailedCrossPodRequestError(&quot;Wrong action '{}' for recv_all_group_delegates&quot;.format(request[&quot;action&quot;]))
</del><ins>+        delegatedUIDs = yield txn.allGroupDelegates()
</ins><span class="cx"> 
</span><del>-        try:
-            delegatedUIDs = yield txn.allGroupDelegates()
-        except Exception as e:
-            returnValue({
-                &quot;result&quot;: &quot;exception&quot;,
-                &quot;class&quot;: &quot;.&quot;.join((e.__class__.__module__, e.__class__.__name__,)),
-                &quot;request&quot;: str(e),
-            })
</del><ins>+        returnValue(list(delegatedUIDs))
</ins><span class="cx"> 
</span><del>-        returnValue({
-            &quot;result&quot;: &quot;ok&quot;,
-            &quot;value&quot;: list(delegatedUIDs),
-        })
</del><span class="cx"> 
</span><del>-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def send_set_delegates(self, txn, delegator, delegates, readWrite):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -98,14 +80,9 @@
</span><span class="cx">             &quot;delegates&quot;: [delegate.uid for delegate in delegates],
</span><span class="cx">             &quot;read-write&quot;: readWrite,
</span><span class="cx">         }
</span><del>-        response = yield self.sendRequestToServer(txn, delegator.server(), request)
</del><ins>+        yield self.sendRequestToServer(txn, delegator.server(), request)
</ins><span class="cx"> 
</span><del>-        if response[&quot;result&quot;] == &quot;ok&quot;:
-            returnValue(None)
-        elif response[&quot;result&quot;] == &quot;exception&quot;:
-            raise namedClass(response[&quot;class&quot;])(response[&quot;result&quot;])
</del><span class="cx"> 
</span><del>-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def recv_set_delegates(self, txn, request):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -115,34 +92,20 @@
</span><span class="cx">         @type request: C{dict}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        if request[&quot;action&quot;] != &quot;set-delegates&quot;:
-            raise FailedCrossPodRequestError(&quot;Wrong action '{}' for recv_set_delegates&quot;.format(request[&quot;action&quot;]))
</del><ins>+        delegator = yield txn.directoryService().recordWithUID(request[&quot;uid&quot;])
+        if delegator is None or not delegator.thisServer():
+            raise FailedCrossPodRequestError(&quot;Cross-pod delegate not on this server: {}&quot;.format(delegator.uid))
</ins><span class="cx"> 
</span><del>-        try:
-            delegator = yield txn.directoryService().recordWithUID(request[&quot;uid&quot;])
-            if delegator is None or not delegator.thisServer():
-                raise FailedCrossPodRequestError(&quot;Cross-pod delegate not on this server: {}&quot;.format(delegator.uid))
</del><ins>+        delegates = []
+        for uid in request[&quot;delegates&quot;]:
+            delegate = yield txn.directoryService().recordWithUID(uid)
+            if delegate is None:
+                raise FailedCrossPodRequestError(&quot;Cross-pod delegate missing on this server: {}&quot;.format(uid))
+            delegates.append(delegate)
</ins><span class="cx"> 
</span><del>-            delegates = []
-            for uid in request[&quot;delegates&quot;]:
-                delegate = yield txn.directoryService().recordWithUID(uid)
-                if delegate is None:
-                    raise FailedCrossPodRequestError(&quot;Cross-pod delegate missing on this server: {}&quot;.format(uid))
-                delegates.append(delegate)
</del><ins>+        yield Delegates.setDelegates(txn, delegator, delegates, request[&quot;read-write&quot;])
</ins><span class="cx"> 
</span><del>-            yield Delegates.setDelegates(txn, delegator, delegates, request[&quot;read-write&quot;])
-        except Exception as e:
-            returnValue({
-                &quot;result&quot;: &quot;exception&quot;,
-                &quot;class&quot;: &quot;.&quot;.join((e.__class__.__module__, e.__class__.__name__,)),
-                &quot;request&quot;: str(e),
-            })
</del><span class="cx"> 
</span><del>-        returnValue({
-            &quot;result&quot;: &quot;ok&quot;,
-        })
-
-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def send_get_delegates(self, txn, delegator, readWrite, expanded=False):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -165,13 +128,9 @@
</span><span class="cx">             &quot;expanded&quot;: expanded,
</span><span class="cx">         }
</span><span class="cx">         response = yield self.sendRequestToServer(txn, delegator.server(), request)
</span><ins>+        returnValue(set(response))
</ins><span class="cx"> 
</span><del>-        if response[&quot;result&quot;] == &quot;ok&quot;:
-            returnValue(set(response[&quot;value&quot;]))
-        elif response[&quot;result&quot;] == &quot;exception&quot;:
-            raise namedClass(response[&quot;class&quot;])(response[&quot;result&quot;])
</del><span class="cx"> 
</span><del>-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def recv_get_delegates(self, txn, request):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -181,28 +140,15 @@
</span><span class="cx">         @type request: C{dict}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        if request[&quot;action&quot;] != &quot;get-delegates&quot;:
-            raise FailedCrossPodRequestError(&quot;Wrong action '{}' for recv_get_delegates&quot;.format(request[&quot;action&quot;]))
</del><ins>+        delegator = yield txn.directoryService().recordWithUID(request[&quot;uid&quot;])
+        if delegator is None or not delegator.thisServer():
+            raise FailedCrossPodRequestError(&quot;Cross-pod delegate not on this server: {}&quot;.format(delegator.uid))
</ins><span class="cx"> 
</span><del>-        try:
-            delegator = yield txn.directoryService().recordWithUID(request[&quot;uid&quot;])
-            if delegator is None or not delegator.thisServer():
-                raise FailedCrossPodRequestError(&quot;Cross-pod delegate not on this server: {}&quot;.format(delegator.uid))
</del><ins>+        delegates = yield Delegates._delegatesOfUIDs(txn, delegator, request[&quot;read-write&quot;], request[&quot;expanded&quot;])
</ins><span class="cx"> 
</span><del>-            delegates = yield Delegates._delegatesOfUIDs(txn, delegator, request[&quot;read-write&quot;], request[&quot;expanded&quot;])
-        except Exception as e:
-            returnValue({
-                &quot;result&quot;: &quot;exception&quot;,
-                &quot;class&quot;: &quot;.&quot;.join((e.__class__.__module__, e.__class__.__name__,)),
-                &quot;request&quot;: str(e),
-            })
</del><ins>+        returnValue(list(delegates))
</ins><span class="cx"> 
</span><del>-        returnValue({
-            &quot;result&quot;: &quot;ok&quot;,
-            &quot;value&quot;: list(delegates),
-        })
</del><span class="cx"> 
</span><del>-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def send_get_delegators(self, txn, server, delegate, readWrite):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -226,13 +172,9 @@
</span><span class="cx">             &quot;read-write&quot;: readWrite,
</span><span class="cx">         }
</span><span class="cx">         response = yield self.sendRequestToServer(txn, server, request)
</span><ins>+        returnValue(set(response))
</ins><span class="cx"> 
</span><del>-        if response[&quot;result&quot;] == &quot;ok&quot;:
-            returnValue(set(response[&quot;value&quot;]))
-        elif response[&quot;result&quot;] == &quot;exception&quot;:
-            raise namedClass(response[&quot;class&quot;])(response[&quot;result&quot;])
</del><span class="cx"> 
</span><del>-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def recv_get_delegators(self, txn, request):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -242,23 +184,10 @@
</span><span class="cx">         @type request: C{dict}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        if request[&quot;action&quot;] != &quot;get-delegators&quot;:
-            raise FailedCrossPodRequestError(&quot;Wrong action '{}' for recv_get_delegators&quot;.format(request[&quot;action&quot;]))
</del><ins>+        delegate = yield txn.directoryService().recordWithUID(request[&quot;uid&quot;])
+        if delegate is None or delegate.thisServer():
+            raise FailedCrossPodRequestError(&quot;Cross-pod delegate missing or on this server: {}&quot;.format(delegate.uid))
</ins><span class="cx"> 
</span><del>-        try:
-            delegate = yield txn.directoryService().recordWithUID(request[&quot;uid&quot;])
-            if delegate is None or delegate.thisServer():
-                raise FailedCrossPodRequestError(&quot;Cross-pod delegate missing or on this server: {}&quot;.format(delegate.uid))
</del><ins>+        delegators = yield Delegates._delegatedToUIDs(txn, delegate, request[&quot;read-write&quot;], onlyThisServer=True)
</ins><span class="cx"> 
</span><del>-            delegateors = yield Delegates._delegatedToUIDs(txn, delegate, request[&quot;read-write&quot;], onlyThisServer=True)
-        except Exception as e:
-            returnValue({
-                &quot;result&quot;: &quot;exception&quot;,
-                &quot;class&quot;: &quot;.&quot;.join((e.__class__.__module__, e.__class__.__name__,)),
-                &quot;request&quot;: str(e),
-            })
-
-        returnValue({
-            &quot;result&quot;: &quot;ok&quot;,
-            &quot;value&quot;: list(delegateors),
-        })
</del><ins>+        returnValue(list(delegators))
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingrequestpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/request.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/request.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/common/datastore/podding/request.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx">                 self.loggedResponse = yield self.logResponse(response)
</span><span class="cx">                 emitAccounting(&quot;xPod&quot;, &quot;&quot;, self.loggedRequest + &quot;\n&quot; + self.loggedResponse, &quot;POST&quot;)
</span><span class="cx"> 
</span><del>-            if response.code in (responsecode.OK,):
</del><ins>+            if response.code in (responsecode.OK, responsecode.BAD_REQUEST,):
</ins><span class="cx">                 data = (yield allDataFromStream(response.stream))
</span><span class="cx">                 data = json.loads(data)
</span><span class="cx">             else:
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingresourcepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/resource.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/resource.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/common/datastore/podding/resource.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -29,7 +29,6 @@
</span><span class="cx">     deliverSchedulePrivilegeSet
</span><span class="cx"> 
</span><span class="cx"> from txdav.xml import element as davxml
</span><del>-from txdav.common.datastore.podding.conduit import FailedCrossPodRequestError
</del><span class="cx"> 
</span><span class="cx"> import base64
</span><span class="cx"> import json
</span><span class="lines">@@ -119,7 +118,7 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">         # Check shared secret
</span><del>-        if not self.store.directoryService().serversDB.getThisServer().checkSharedSecret(request.headers):
</del><ins>+        if not self.store.directoryService().serversDB().getThisServer().checkSharedSecret(request.headers):
</ins><span class="cx">             self.log.error(&quot;Invalid shared secret header in cross-pod request&quot;)
</span><span class="cx">             raise HTTPError(StatusResponse(responsecode.FORBIDDEN, &quot;Not authorized to make this request&quot;))
</span><span class="cx"> 
</span><span class="lines">@@ -158,12 +157,17 @@
</span><span class="cx">         # Get the conduit to process the data
</span><span class="cx">         try:
</span><span class="cx">             result = yield self.store.conduit.processRequest(j)
</span><del>-        except FailedCrossPodRequestError as e:
-            raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, str(e)))
</del><ins>+            code = responsecode.OK
</ins><span class="cx">         except Exception as e:
</span><del>-            raise HTTPError(StatusResponse(responsecode.INTERNAL_SERVER_ERROR, str(e)))
</del><ins>+            # Send the exception over to the other side
+            result = {
+                &quot;result&quot;: &quot;exception&quot;,
+                &quot;class&quot;: &quot;.&quot;.join((e.__class__.__module__, e.__class__.__name__,)),
+                &quot;request&quot;: str(e),
+            }
+            code = responsecode.BAD_REQUEST
</ins><span class="cx"> 
</span><del>-        response = JSONResponse(responsecode.OK, result)
</del><ins>+        response = JSONResponse(code, result)
</ins><span class="cx">         returnValue(response)
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingsharing_basepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/sharing_base.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/sharing_base.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/common/datastore/podding/sharing_base.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def _getResourcesForRequest(self, txn, request, expected_action):
</del><ins>+    def _getResourcesForRequest(self, txn, request):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Find the resources associated with the request. This is used when a JSON request has been received
</span><span class="cx">         and the underlying store objects the request refers to need to be found.
</span><span class="lines">@@ -67,9 +67,6 @@
</span><span class="cx">         @type request: C{dict}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        if request[&quot;action&quot;] != expected_action:
-            raise FailedCrossPodRequestError(&quot;Wrong action '{}' for recv_{}&quot;.format(request[&quot;action&quot;], expected_action))
-
</del><span class="cx">         # Get a share
</span><span class="cx">         ownerHome = yield txn.homeWithUID(request[&quot;type&quot;], request[&quot;owner&quot;])
</span><span class="cx">         if ownerHome is None or ownerHome.external():
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingsharing_invitespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/sharing_invites.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/sharing_invites.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/common/datastore/podding/sharing_invites.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -14,9 +14,8 @@
</span><span class="cx"> # limitations under the License.
</span><span class="cx"> ##
</span><span class="cx"> 
</span><del>-from twisted.internet.defer import inlineCallbacks, returnValue
</del><ins>+from twisted.internet.defer import inlineCallbacks
</ins><span class="cx"> 
</span><del>-from txdav.common.icommondatastore import ExternalShareFailed
</del><span class="cx"> from txdav.common.datastore.podding.base import FailedCrossPodRequestError
</span><span class="cx"> from txdav.common.datastore.podding.sharing_base import SharingCommonPoddingConduit
</span><span class="cx"> 
</span><span class="lines">@@ -71,8 +70,7 @@
</span><span class="cx">         if supported_components is not None:
</span><span class="cx">             request[&quot;supported-components&quot;] = supported_components
</span><span class="cx"> 
</span><del>-        result = yield self.sendRequest(txn, recipient, request)
-        returnValue(result)
</del><ins>+        yield self.sendRequest(txn, recipient, request)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -84,34 +82,24 @@
</span><span class="cx">         @type request: C{dict}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        if request[&quot;action&quot;] != &quot;shareinvite&quot;:
-            raise FailedCrossPodRequestError(&quot;Wrong action '{}' for recv_shareinvite&quot;.format(request[&quot;action&quot;]))
-
</del><span class="cx">         # Sharee home on this pod must exist (create if needed)
</span><span class="cx">         shareeHome = yield txn.homeWithUID(request[&quot;type&quot;], request[&quot;sharee&quot;], create=True)
</span><span class="cx">         if shareeHome is None or shareeHome.external():
</span><span class="cx">             raise FailedCrossPodRequestError(&quot;Invalid sharee UID specified&quot;)
</span><span class="cx"> 
</span><span class="cx">         # Create a share
</span><del>-        try:
-            yield shareeHome.processExternalInvite(
-                request[&quot;owner&quot;],
-                request[&quot;owner_id&quot;],
-                request[&quot;owner_name&quot;],
-                request[&quot;share_id&quot;],
-                request[&quot;mode&quot;],
-                request[&quot;summary&quot;],
-                request[&quot;properties&quot;],
-                supported_components=request.get(&quot;supported-components&quot;)
-            )
-        except ExternalShareFailed as e:
-            raise FailedCrossPodRequestError(str(e))
</del><ins>+        yield shareeHome.processExternalInvite(
+            request[&quot;owner&quot;],
+            request[&quot;owner_id&quot;],
+            request[&quot;owner_name&quot;],
+            request[&quot;share_id&quot;],
+            request[&quot;mode&quot;],
+            request[&quot;summary&quot;],
+            request[&quot;properties&quot;],
+            supported_components=request.get(&quot;supported-components&quot;)
+        )
</ins><span class="cx"> 
</span><del>-        returnValue({
-            &quot;result&quot;: &quot;ok&quot;,
-        })
</del><span class="cx"> 
</span><del>-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def send_shareuninvite(self, txn, homeType, ownerUID, ownerID, shareeUID, shareUID):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -140,8 +128,7 @@
</span><span class="cx">             &quot;share_id&quot;: shareUID,
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        result = yield self.sendRequest(txn, recipient, request)
-        returnValue(result)
</del><ins>+        yield self.sendRequest(txn, recipient, request)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -153,29 +140,19 @@
</span><span class="cx">         @type request: C{dict}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        if request[&quot;action&quot;] != &quot;shareuninvite&quot;:
-            raise FailedCrossPodRequestError(&quot;Wrong action '{}' for recv_shareuninvite&quot;.format(request[&quot;action&quot;]))
-
</del><span class="cx">         # Sharee home on this pod must already exist
</span><span class="cx">         shareeHome = yield txn.homeWithUID(request[&quot;type&quot;], request[&quot;sharee&quot;])
</span><span class="cx">         if shareeHome is None or shareeHome.external():
</span><span class="cx">             FailedCrossPodRequestError(&quot;Invalid sharee UID specified&quot;)
</span><span class="cx"> 
</span><span class="cx">         # Remove a share
</span><del>-        try:
-            yield shareeHome.processExternalUninvite(
-                request[&quot;owner&quot;],
-                request[&quot;owner_id&quot;],
-                request[&quot;share_id&quot;],
-            )
-        except ExternalShareFailed as e:
-            FailedCrossPodRequestError(str(e))
</del><ins>+        yield shareeHome.processExternalUninvite(
+            request[&quot;owner&quot;],
+            request[&quot;owner_id&quot;],
+            request[&quot;share_id&quot;],
+        )
</ins><span class="cx"> 
</span><del>-        returnValue({
-            &quot;result&quot;: &quot;ok&quot;,
-        })
</del><span class="cx"> 
</span><del>-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def send_sharereply(self, txn, homeType, ownerUID, shareeUID, shareUID, bindStatus, summary=None):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -208,8 +185,7 @@
</span><span class="cx">         if summary is not None:
</span><span class="cx">             request[&quot;summary&quot;] = summary
</span><span class="cx"> 
</span><del>-        result = yield self.sendRequest(txn, recipient, request)
-        returnValue(result)
</del><ins>+        yield self.sendRequest(txn, recipient, request)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -221,26 +197,16 @@
</span><span class="cx">         @type request: C{dict}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        if request[&quot;action&quot;] != &quot;sharereply&quot;:
-            raise FailedCrossPodRequestError(&quot;Wrong action '{}' for recv_sharereply&quot;.format(request[&quot;action&quot;]))
-
</del><span class="cx">         # Sharer home on this pod must already exist
</span><span class="cx">         ownerHome = yield txn.homeWithUID(request[&quot;type&quot;], request[&quot;owner&quot;])
</span><span class="cx">         if ownerHome is None or ownerHome.external():
</span><span class="cx">             FailedCrossPodRequestError(&quot;Invalid owner UID specified&quot;)
</span><span class="cx"> 
</span><span class="cx">         # Process a reply
</span><del>-        try:
-            yield ownerHome.processExternalReply(
-                request[&quot;owner&quot;],
-                request[&quot;sharee&quot;],
-                request[&quot;share_id&quot;],
-                request[&quot;status&quot;],
-                summary=request.get(&quot;summary&quot;)
-            )
-        except ExternalShareFailed as e:
-            FailedCrossPodRequestError(str(e))
-
-        returnValue({
-            &quot;result&quot;: &quot;ok&quot;,
-        })
</del><ins>+        yield ownerHome.processExternalReply(
+            request[&quot;owner&quot;],
+            request[&quot;sharee&quot;],
+            request[&quot;share_id&quot;],
+            request[&quot;status&quot;],
+            summary=request.get(&quot;summary&quot;)
+        )
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingsharing_storepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/sharing_store.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/sharing_store.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/common/datastore/podding/sharing_store.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -15,7 +15,6 @@
</span><span class="cx"> ##
</span><span class="cx"> 
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><del>-from twisted.python.reflect import namedClass
</del><span class="cx"> 
</span><span class="cx"> from txdav.common.datastore.podding.sharing_base import SharingCommonPoddingConduit
</span><span class="cx"> from txdav.caldav.datastore.scheduling.freebusy import generateFreeBusyInfo
</span><span class="lines">@@ -59,10 +58,7 @@
</span><span class="cx">         if kwargs is not None:
</span><span class="cx">             request[&quot;keywords&quot;] = kwargs
</span><span class="cx">         response = yield self.sendRequest(shareeView._txn, recipient, request)
</span><del>-        if response[&quot;result&quot;] == &quot;ok&quot;:
-            returnValue(response[&quot;value&quot;] if transform is None else transform(response[&quot;value&quot;], shareeView, objectResource))
-        elif response[&quot;result&quot;] == &quot;exception&quot;:
-            raise namedClass(response[&quot;class&quot;])(response[&quot;result&quot;])
</del><ins>+        returnValue(response if transform is None else transform(response, shareeView, objectResource))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -81,29 +77,19 @@
</span><span class="cx">         @type transform: C{callable}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        shareeView, objectResource = yield self._getResourcesForRequest(txn, request, actionName)
-        try:
-            if onHomeChild:
-                # Operate on the L{CommonHomeChild}
-                value = yield getattr(shareeView, method)(*request.get(&quot;arguments&quot;, ()), **request.get(&quot;keywords&quot;, {}))
</del><ins>+        shareeView, objectResource = yield self._getResourcesForRequest(txn, request)
+        if onHomeChild:
+            # Operate on the L{CommonHomeChild}
+            value = yield getattr(shareeView, method)(*request.get(&quot;arguments&quot;, ()), **request.get(&quot;keywords&quot;, {}))
+        else:
+            # Operate on the L{CommonObjectResource}
+            if objectResource is not None:
+                value = yield getattr(objectResource, method)(*request.get(&quot;arguments&quot;, ()), **request.get(&quot;keywords&quot;, {}))
</ins><span class="cx">             else:
</span><del>-                # Operate on the L{CommonObjectResource}
-                if objectResource is not None:
-                    value = yield getattr(objectResource, method)(*request.get(&quot;arguments&quot;, ()), **request.get(&quot;keywords&quot;, {}))
-                else:
-                    # classmethod call
-                    value = yield getattr(shareeView._objectResourceClass, method)(shareeView, *request.get(&quot;arguments&quot;, ()), **request.get(&quot;keywords&quot;, {}))
-        except Exception as e:
-            returnValue({
-                &quot;result&quot;: &quot;exception&quot;,
-                &quot;class&quot;: &quot;.&quot;.join((e.__class__.__module__, e.__class__.__name__,)),
-                &quot;request&quot;: str(e),
-            })
</del><ins>+                # classmethod call
+                value = yield getattr(shareeView._objectResourceClass, method)(shareeView, *request.get(&quot;arguments&quot;, ()), **request.get(&quot;keywords&quot;, {}))
</ins><span class="cx"> 
</span><del>-        returnValue({
-            &quot;result&quot;: &quot;ok&quot;,
-            &quot;value&quot;: transform(value, shareeView, objectResource) if transform is not None else value,
-        })
</del><ins>+        returnValue(transform(value, shareeView, objectResource) if transform is not None else value)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -134,13 +120,9 @@
</span><span class="cx">         action[&quot;event_details&quot;] = event_details
</span><span class="cx"> 
</span><span class="cx">         response = yield self.sendRequest(calresource._txn, recipient, action)
</span><ins>+        returnValue((response[&quot;fbresults&quot;], response[&quot;matchtotal&quot;],))
</ins><span class="cx"> 
</span><del>-        if response[&quot;result&quot;] == &quot;ok&quot;:
-            returnValue((response[&quot;fbresults&quot;], response[&quot;matchtotal&quot;],))
-        elif response[&quot;result&quot;] == &quot;exception&quot;:
-            raise namedClass(response[&quot;class&quot;])(response[&quot;result&quot;])
</del><span class="cx"> 
</span><del>-
</del><span class="cx">     @inlineCallbacks
</span><span class="cx">     def recv_freebusy(self, txn, request):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -150,37 +132,30 @@
</span><span class="cx">         @type request: C{dict}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        shareeView, _ignore_objectResource = yield self._getResourcesForRequest(txn, request, &quot;freebusy&quot;)
-        try:
-            # Operate on the L{CommonHomeChild}
-            fbinfo = [[], [], []]
-            matchtotal = yield generateFreeBusyInfo(
-                shareeView,
-                fbinfo,
-                TimeRange(start=request[&quot;timerange&quot;][0], end=request[&quot;timerange&quot;][1]),
-                request[&quot;matchtotal&quot;],
-                request[&quot;excludeuid&quot;],
-                request[&quot;organizer&quot;],
-                request[&quot;organizerPrincipal&quot;],
-                request[&quot;same_calendar_user&quot;],
-                request[&quot;servertoserver&quot;],
-                request[&quot;event_details&quot;],
-                logItems=None
-            )
-        except Exception as e:
-            returnValue({
-                &quot;result&quot;: &quot;exception&quot;,
-                &quot;class&quot;: &quot;.&quot;.join((e.__class__.__module__, e.__class__.__name__,)),
-                &quot;request&quot;: str(e),
-            })
</del><ins>+        # Operate on the L{CommonHomeChild}
+        shareeView, _ignore_objectResource = yield self._getResourcesForRequest(txn, request)
</ins><span class="cx"> 
</span><ins>+        fbinfo = [[], [], []]
+        matchtotal = yield generateFreeBusyInfo(
+            shareeView,
+            fbinfo,
+            TimeRange(start=request[&quot;timerange&quot;][0], end=request[&quot;timerange&quot;][1]),
+            request[&quot;matchtotal&quot;],
+            request[&quot;excludeuid&quot;],
+            request[&quot;organizer&quot;],
+            request[&quot;organizerPrincipal&quot;],
+            request[&quot;same_calendar_user&quot;],
+            request[&quot;servertoserver&quot;],
+            request[&quot;event_details&quot;],
+            logItems=None
+        )
+
</ins><span class="cx">         # Convert L{DateTime} objects to text for JSON response
</span><span class="cx">         for i in range(3):
</span><span class="cx">             for j in range(len(fbinfo[i])):
</span><span class="cx">                 fbinfo[i][j] = fbinfo[i][j].getText()
</span><span class="cx"> 
</span><span class="cx">         returnValue({
</span><del>-            &quot;result&quot;: &quot;ok&quot;,
</del><span class="cx">             &quot;fbresults&quot;: fbinfo,
</span><span class="cx">             &quot;matchtotal&quot;: matchtotal,
</span><span class="cx">         })
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingtesttest_conduitpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/test/test_conduit.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/test/test_conduit.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/common/datastore/podding/test/test_conduit.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -52,7 +52,6 @@
</span><span class="cx"> 
</span><span class="cx">         def recv_fake(self, j):
</span><span class="cx">             return succeed({
</span><del>-                &quot;result&quot;: &quot;ok&quot;,
</del><span class="cx">                 &quot;back2u&quot;: j[&quot;echo&quot;],
</span><span class="cx">                 &quot;more&quot;: &quot;bits&quot;,
</span><span class="cx">             })
</span><span class="lines">@@ -149,7 +148,6 @@
</span><span class="cx"> 
</span><span class="cx">         def recv_fake(self, txn, j):
</span><span class="cx">             return succeed({
</span><del>-                &quot;result&quot;: &quot;ok&quot;,
</del><span class="cx">                 &quot;back2u&quot;: j[&quot;echo&quot;],
</span><span class="cx">                 &quot;more&quot;: &quot;bits&quot;,
</span><span class="cx">             })
</span><span class="lines">@@ -173,23 +171,13 @@
</span><span class="cx">         txn = self.transactionUnderTest()
</span><span class="cx">         store1 = self.storeUnderTest()
</span><span class="cx">         response = yield store1.conduit.send_fake(txn, &quot;user01&quot;, &quot;puser01&quot;)
</span><del>-        self.assertTrue(&quot;result&quot; in response)
-        self.assertEqual(response[&quot;result&quot;], &quot;ok&quot;)
-        self.assertTrue(&quot;back2u&quot; in response)
-        self.assertEqual(response[&quot;back2u&quot;], &quot;bravo&quot;)
-        self.assertTrue(&quot;more&quot; in response)
-        self.assertEqual(response[&quot;more&quot;], &quot;bits&quot;)
</del><ins>+        self.assertEqual(response, {&quot;back2u&quot;: &quot;bravo&quot;, &quot;more&quot;: &quot;bits&quot;})
</ins><span class="cx">         yield txn.commit()
</span><span class="cx"> 
</span><span class="cx">         store2 = self.otherStoreUnderTest()
</span><span class="cx">         txn = store2.newTransaction()
</span><span class="cx">         response = yield store2.conduit.send_fake(txn, &quot;puser01&quot;, &quot;user01&quot;)
</span><del>-        self.assertTrue(&quot;result&quot; in response)
-        self.assertEqual(response[&quot;result&quot;], &quot;ok&quot;)
-        self.assertTrue(&quot;back2u&quot; in response)
-        self.assertEqual(response[&quot;back2u&quot;], &quot;bravo&quot;)
-        self.assertTrue(&quot;more&quot; in response)
-        self.assertEqual(response[&quot;more&quot;], &quot;bits&quot;)
</del><ins>+        self.assertEqual(response, {&quot;back2u&quot;: &quot;bravo&quot;, &quot;more&quot;: &quot;bits&quot;})
</ins><span class="cx">         yield txn.commit()
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingtesttest_resourcepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/test/test_resource.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/test/test_resource.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/common/datastore/podding/test/test_resource.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -37,7 +37,6 @@
</span><span class="cx"> 
</span><span class="cx">         def recv_fake(self, txn, j):
</span><span class="cx">             return succeed({
</span><del>-                &quot;result&quot;: &quot;ok&quot;,
</del><span class="cx">                 &quot;back2u&quot;: j[&quot;echo&quot;],
</span><span class="cx">                 &quot;more&quot;: &quot;bits&quot;,
</span><span class="cx">             })
</span><span class="lines">@@ -266,7 +265,5 @@
</span><span class="cx">         j = json.loads(data)
</span><span class="cx">         self.assertTrue(&quot;result&quot; in j)
</span><span class="cx">         self.assertEqual(j[&quot;result&quot;], &quot;ok&quot;)
</span><del>-        self.assertTrue(&quot;back2u&quot; in j)
-        self.assertEqual(j[&quot;back2u&quot;], &quot;bravo&quot;)
-        self.assertTrue(&quot;more&quot; in j)
-        self.assertEqual(j[&quot;more&quot;], &quot;bits&quot;)
</del><ins>+        self.assertTrue(&quot;value&quot; in j)
+        self.assertEqual(j[&quot;value&quot;], {&quot;back2u&quot;: &quot;bravo&quot;, &quot;more&quot;: &quot;bits&quot;})
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingtestutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/test/util.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/test/util.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/common/datastore/podding/test/util.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -89,7 +89,15 @@
</span><span class="cx">         if self.stream is not None:
</span><span class="cx">             j[&quot;stream&quot;] = self.stream
</span><span class="cx">             j[&quot;streamType&quot;] = self.streamType
</span><del>-        result = yield store.conduit.processRequest(j)
</del><ins>+        try:
+            result = yield store.conduit.processRequest(j)
+        except Exception as e:
+            # Send the exception over to the other side
+            result = {
+                &quot;result&quot;: &quot;exception&quot;,
+                &quot;class&quot;: &quot;.&quot;.join((e.__class__.__module__, e.__class__.__name__,)),
+                &quot;request&quot;: str(e),
+            }
</ins><span class="cx">         result = json.dumps(result)
</span><span class="cx">         returnValue(result)
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhocachepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/cache.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/cache.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/who/cache.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -473,6 +473,10 @@
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def serversDB(self):
+        return self._directory.serversDB()
+
+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def flush(self):
</span><span class="cx">         self.resetCache()
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhodelegatespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/delegates.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/delegates.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/who/delegates.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -614,7 +614,7 @@
</span><span class="cx">         log.debug(&quot;_podDelegators for: {} and read-write = {}&quot;.format(delegate.uid, readWrite,))
</span><span class="cx">         results = yield DeferredList([
</span><span class="cx">             txn.store().conduit.send_get_delegators(txn, server, delegate, readWrite) for
</span><del>-            server in txn.directoryService().serversDB.allServersExceptThis()
</del><ins>+            server in txn.directoryService().serversDB().allServersExceptThis()
</ins><span class="cx">         ], consumeErrors=True)
</span><span class="cx">         delegators = set()
</span><span class="cx">         for result in results:
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhodirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/directory.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/directory.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/who/directory.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -53,10 +53,14 @@
</span><span class="cx"> 
</span><span class="cx">     guid = &quot;1332A615-4D3A-41FE-B636-FBE25BFB982E&quot;
</span><span class="cx"> 
</span><del>-    serversDB = None
</del><ins>+    _serversDB = None
</ins><span class="cx"> 
</span><ins>+    def serversDB(self):
+        return self._serversDB
+
+
</ins><span class="cx">     def setServersDB(self, serversDB):
</span><del>-        self.serversDB = serversDB
</del><ins>+        self._serversDB = serversDB
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     # Must maintain the hack for a bit longer:
</span><span class="lines">@@ -502,10 +506,10 @@
</span><span class="cx">         URL of the server hosting this record. Return None if hosted on this server.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         if (
</span><del>-            self.service.serversDB is not None and
</del><ins>+            self.service.serversDB() is not None and
</ins><span class="cx">             getattr(self, &quot;serviceNodeUID&quot;, None)
</span><span class="cx">         ):
</span><del>-            return self.service.serversDB.getServerURIById(self.serviceNodeUID)
</del><ins>+            return self.service.serversDB().getServerURIById(self.serviceNodeUID)
</ins><span class="cx">         else:
</span><span class="cx">             return None
</span><span class="cx"> 
</span><span class="lines">@@ -515,10 +519,10 @@
</span><span class="cx">         Server hosting this record. Return None if hosted on this server.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         if (
</span><del>-            self.service.serversDB is not None and
</del><ins>+            self.service.serversDB() is not None and
</ins><span class="cx">             getattr(self, &quot;serviceNodeUID&quot;, None)
</span><span class="cx">         ):
</span><del>-            return self.service.serversDB.getServerById(self.serviceNodeUID)
</del><ins>+            return self.service.serversDB().getServerById(self.serviceNodeUID)
</ins><span class="cx">         else:
</span><span class="cx">             return None
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhogroupspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/groups.py (14306 => 14307)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/groups.py        2015-01-15 17:56:24 UTC (rev 14306)
+++ CalendarServer/trunk/txdav/who/groups.py        2015-01-15 18:11:02 UTC (rev 14307)
</span><span class="lines">@@ -533,10 +533,10 @@
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         # Also get group delegates from other pods
</span><del>-        if txn.directoryService().serversDB is not None and len(txn.directoryService().serversDB.allServersExceptThis()) != 0:
</del><ins>+        if txn.directoryService().serversDB() is not None and len(txn.directoryService().serversDB().allServersExceptThis()) != 0:
</ins><span class="cx">             results = yield DeferredList([
</span><span class="cx">                 txn.store().conduit.send_all_group_delegates(txn, server) for
</span><del>-                server in txn.directoryService().serversDB.allServersExceptThis()
</del><ins>+                server in txn.directoryService().serversDB().allServersExceptThis()
</ins><span class="cx">             ], consumeErrors=True)
</span><span class="cx">             for result in results:
</span><span class="cx">                 if result and result[0]:
</span></span></pre>
</div>
</div>

</body>
</html>