<!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>[11817] 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/11817">11817</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2013-10-15 16:24:11 -0700 (Tue, 15 Oct 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Don't create new transactions for adding push work items -- create them within the transaction whose changes caused the notification in the first place.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcalendarserverpushnotifierpy">CalendarServer/trunk/calendarserver/push/notifier.py</a></li>
<li><a href="#CalendarServertrunkcalendarserverpushtesttest_notifierpy">CalendarServer/trunk/calendarserver/push/test/test_notifier.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoretestcommonpy">CalendarServer/trunk/txdav/caldav/datastore/test/common.py</a></li>
<li><a href="#CalendarServertrunktxdavcarddavdatastoretestcommonpy">CalendarServer/trunk/txdav/carddav/datastore/test/common.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorefilepy">CalendarServer/trunk/txdav/common/datastore/file.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresqlpy">CalendarServer/trunk/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoretestutilpy">CalendarServer/trunk/txdav/common/datastore/test/util.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcalendarserverpushnotifierpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/push/notifier.py (11816 => 11817)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/push/notifier.py        2013-10-15 17:00:57 UTC (rev 11816)
+++ CalendarServer/trunk/calendarserver/push/notifier.py        2013-10-15 23:24:11 UTC (rev 11817)
</span><span class="lines">@@ -84,10 +84,13 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def notify(self):
</del><ins>+ def notify(self, txn):
</ins><span class="cx"> """
</span><span class="cx"> Send the notification. For a home object we just push using the home id. For a home
</span><span class="cx"> child we push both the owner home id and the owned home child id.
</span><ins>+
+ @param txn: The transaction to create the work item with
+ @type txn: L{CommonStoreTransaction}
</ins><span class="cx"> """
</span><span class="cx"> # Push ids from the store objects are a tuple of (prefix, name,) and we need to compose that
</span><span class="cx"> # into a single token.
</span><span class="lines">@@ -100,7 +103,7 @@
</span><span class="cx"> for prefix, id in ids:
</span><span class="cx"> if self._notify:
</span><span class="cx"> self.log.debug("Notifications are enabled: %s %s/%s" % (self._storeObject, prefix, id,))
</span><del>- yield self._notifierFactory.send(prefix, id)
</del><ins>+ yield self._notifierFactory.send(prefix, id, txn)
</ins><span class="cx"> else:
</span><span class="cx"> self.log.debug("Skipping notification for: %s %s/%s" % (self._storeObject, prefix, id,))
</span><span class="cx">
</span><span class="lines">@@ -147,11 +150,12 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def send(self, prefix, id):
- txn = self.store.newTransaction()
</del><ins>+ def send(self, prefix, id, txn):
+ """
+ Enqueue a push notification work item on the provided transaction.
+ """
</ins><span class="cx"> notBefore = datetime.datetime.utcnow() + datetime.timedelta(seconds=self.coalesceSeconds)
</span><span class="cx"> yield txn.enqueue(PushNotificationWork, pushID=self.pushKeyForId(prefix, id), notBefore=notBefore)
</span><del>- yield txn.commit()
</del><span class="cx">
</span><span class="cx">
</span><span class="cx"> def newNotifier(self, storeObject):
</span></span></pre></div>
<a id="CalendarServertrunkcalendarserverpushtesttest_notifierpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/push/test/test_notifier.py (11816 => 11817)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/push/test/test_notifier.py        2013-10-15 17:00:57 UTC (rev 11816)
+++ CalendarServer/trunk/calendarserver/push/test/test_notifier.py        2013-10-15 23:24:11 UTC (rev 11817)
</span><span class="lines">@@ -169,8 +169,8 @@
</span><span class="cx">
</span><span class="cx"> home = yield self.homeUnderTest()
</span><span class="cx"> yield home.notifyChanged()
</span><ins>+ self.assertEquals(self.notifierFactory.history, ["/CalDAV/example.com/home1/"])
</ins><span class="cx"> yield self.commit()
</span><del>- self.assertEquals(self.notifierFactory.history, ["/CalDAV/example.com/home1/"])
</del><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -178,11 +178,11 @@
</span><span class="cx">
</span><span class="cx"> calendar = yield self.calendarUnderTest()
</span><span class="cx"> yield calendar.notifyChanged()
</span><del>- yield self.commit()
</del><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set(["/CalDAV/example.com/home1/", "/CalDAV/example.com/home1/calendar_1/"])
</span><span class="cx"> )
</span><ins>+ yield self.commit()
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -191,7 +191,6 @@
</span><span class="cx"> calendar = yield self.calendarUnderTest()
</span><span class="cx"> home2 = yield self.homeUnderTest(name="home2")
</span><span class="cx"> yield calendar.shareWith(home2, _BIND_MODE_WRITE)
</span><del>- yield self.commit()
</del><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set([
</span><span class="lines">@@ -200,11 +199,11 @@
</span><span class="cx"> "/CalDAV/example.com/home2/"
</span><span class="cx"> ])
</span><span class="cx"> )
</span><ins>+ yield self.commit()
</ins><span class="cx">
</span><span class="cx"> calendar = yield self.calendarUnderTest()
</span><span class="cx"> home2 = yield self.homeUnderTest(name="home2")
</span><span class="cx"> yield calendar.unshareWith(home2)
</span><del>- yield self.commit()
</del><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set([
</span><span class="lines">@@ -213,6 +212,7 @@
</span><span class="cx"> "/CalDAV/example.com/home2/"
</span><span class="cx"> ])
</span><span class="cx"> )
</span><ins>+ yield self.commit()
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -226,11 +226,11 @@
</span><span class="cx">
</span><span class="cx"> shared = yield self.calendarUnderTest(home="home2", name=shareName)
</span><span class="cx"> yield shared.notifyChanged()
</span><del>- yield self.commit()
</del><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set(["/CalDAV/example.com/home1/", "/CalDAV/example.com/home1/calendar_1/"])
</span><span class="cx"> )
</span><ins>+ yield self.commit()
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -238,8 +238,8 @@
</span><span class="cx">
</span><span class="cx"> notifications = yield self.transactionUnderTest().notificationsWithUID("home1")
</span><span class="cx"> yield notifications.notifyChanged()
</span><del>- yield self.commit()
</del><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set(["/CalDAV/example.com/home1/", "/CalDAV/example.com/home1/notification/"])
</span><span class="cx"> )
</span><ins>+ yield self.commit()
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoretestcommonpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/test/common.py (11816 => 11817)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/test/common.py        2013-10-15 17:00:57 UTC (rev 11816)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/common.py        2013-10-15 23:24:11 UTC (rev 11817)
</span><span class="lines">@@ -450,9 +450,7 @@
</span><span class="cx"> yield notifications.writeNotificationObject("abc", inviteNotification,
</span><span class="cx"> inviteNotification.toxml())
</span><span class="cx">
</span><del>- yield self.commit()
-
- # Make sure notification fired after commit
</del><ins>+ # notify is called prior to commit
</ins><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set([
</span><span class="lines">@@ -460,6 +458,7 @@
</span><span class="cx"> "/CalDAV/example.com/home1/notification/",
</span><span class="cx"> ])
</span><span class="cx"> )
</span><ins>+ yield self.commit()
</ins><span class="cx">
</span><span class="cx"> notifications = yield self.transactionUnderTest().notificationsWithUID(
</span><span class="cx"> "home1"
</span><span class="lines">@@ -469,9 +468,7 @@
</span><span class="cx"> abc = yield notifications.notificationObjectWithUID("abc")
</span><span class="cx"> self.assertEquals(abc, None)
</span><span class="cx">
</span><del>- yield self.commit()
-
- # Make sure notification fired after commit
</del><ins>+ # notify is called prior to commit
</ins><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set([
</span><span class="lines">@@ -479,6 +476,7 @@
</span><span class="cx"> "/CalDAV/example.com/home1/notification/",
</span><span class="cx"> ])
</span><span class="cx"> )
</span><ins>+ yield self.commit()
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -697,11 +695,10 @@
</span><span class="cx"> self.assertNotIdentical((yield home.calendarWithName(name)), None)
</span><span class="cx"> calendarProperties = (yield home.calendarWithName(name)).properties()
</span><span class="cx"> self.assertEqual(len(calendarProperties), 0)
</span><ins>+ # notify is called prior to commit
+ self.assertTrue("/CalDAV/example.com/home1/" in self.notifierFactory.history)
</ins><span class="cx"> yield self.commit()
</span><span class="cx">
</span><del>- # Make sure notification fired after commit
- self.assertTrue("/CalDAV/example.com/home1/" in self.notifierFactory.history)
-
</del><span class="cx"> # Make sure it's available in a new transaction; i.e. test the commit.
</span><span class="cx"> home = yield self.homeUnderTest()
</span><span class="cx"> self.assertNotIdentical((yield home.calendarWithName(name)), None)
</span><span class="lines">@@ -915,8 +912,7 @@
</span><span class="cx"> None
</span><span class="cx"> )
</span><span class="cx">
</span><del>- # Make sure notifications are fired after commit
- yield self.commit()
</del><ins>+ # notify is called prior to commit
</ins><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set([
</span><span class="lines">@@ -924,6 +920,7 @@
</span><span class="cx"> "/CalDAV/example.com/home1/calendar_1/",
</span><span class="cx"> ])
</span><span class="cx"> )
</span><ins>+ yield self.commit()
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -1471,9 +1468,7 @@
</span><span class="cx"> self.assertEquals((yield calendarObject.componentForUser()), component)
</span><span class="cx"> self.assertEquals((yield calendarObject.getMetadata()), metadata)
</span><span class="cx">
</span><del>- yield self.commit()
-
- # Make sure notifications fire after commit
</del><ins>+ # notify is called prior to commit
</ins><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set([
</span><span class="lines">@@ -1481,6 +1476,7 @@
</span><span class="cx"> "/CalDAV/example.com/home1/calendar_1/",
</span><span class="cx"> ])
</span><span class="cx"> )
</span><ins>+ yield self.commit()
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -1591,9 +1587,7 @@
</span><span class="cx"> calendarObject = yield calendar1.calendarObjectWithName("1.ics")
</span><span class="cx"> self.assertEquals((yield calendarObject.componentForUser()), component)
</span><span class="cx">
</span><del>- yield self.commit()
-
- # Make sure notification fired after commit
</del><ins>+ # notify is called prior to commit
</ins><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set([
</span><span class="lines">@@ -1601,6 +1595,7 @@
</span><span class="cx"> "/CalDAV/example.com/home1/calendar_1/",
</span><span class="cx"> ])
</span><span class="cx"> )
</span><ins>+ yield self.commit()
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def checkPropertiesMethod(self, thunk):
</span></span></pre></div>
<a id="CalendarServertrunktxdavcarddavdatastoretestcommonpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/carddav/datastore/test/common.py (11816 => 11817)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/carddav/datastore/test/common.py        2013-10-15 17:00:57 UTC (rev 11816)
+++ CalendarServer/trunk/txdav/carddav/datastore/test/common.py        2013-10-15 23:24:11 UTC (rev 11817)
</span><span class="lines">@@ -371,10 +371,10 @@
</span><span class="cx"> #self.assertIdentical((yield home.addressbookWithName(name)), None)
</span><span class="cx"> yield home.removeAddressBookWithName(name)
</span><span class="cx"> self.assertNotIdentical((yield home.addressbookWithName(name)), None)
</span><ins>+ # notify is called prior to commit
+ self.assertTrue("/CardDAV/example.com/home1/" in self.notifierFactory.history)
</ins><span class="cx"> yield self.commit()
</span><span class="cx">
</span><del>- # Make sure notification fired after commit
- self.assertTrue("/CardDAV/example.com/home1/" in self.notifierFactory.history)
</del><span class="cx">
</span><span class="cx"> # Make sure it's available in a new transaction; i.e. test the commit.
</span><span class="cx"> home = yield self.homeUnderTest()
</span><span class="lines">@@ -396,9 +396,7 @@
</span><span class="cx"> ab = yield home.addressbookWithName(name)
</span><span class="cx"> self.assertEquals((yield ab.listAddressBookObjects()), [])
</span><span class="cx">
</span><del>- yield self.commit()
-
- # Make sure notification fired after commit
</del><ins>+ # notify is called prior to commit
</ins><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set([
</span><span class="lines">@@ -407,7 +405,10 @@
</span><span class="cx"> ])
</span><span class="cx"> )
</span><span class="cx">
</span><ins>+ yield self.commit()
</ins><span class="cx">
</span><ins>+
+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_removeAddressBookWithName_absent(self):
</span><span class="cx"> """
</span><span class="lines">@@ -530,8 +531,6 @@
</span><span class="cx"> (yield addressbook.addressbookObjectWithName(name)), None
</span><span class="cx"> )
</span><span class="cx">
</span><del>- # Make sure notifications are fired after commit
- yield self.commit()
</del><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set([
</span><span class="lines">@@ -692,9 +691,7 @@
</span><span class="cx"> addressbookObject = yield addressbook1.addressbookObjectWithName(name)
</span><span class="cx"> self.assertEquals((yield addressbookObject.component()), component)
</span><span class="cx">
</span><del>- yield self.commit()
-
- # Make sure notifications fire after commit
</del><ins>+ # notify is called prior to commit
</ins><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set([
</span><span class="lines">@@ -703,7 +700,9 @@
</span><span class="cx"> ])
</span><span class="cx"> )
</span><span class="cx">
</span><ins>+ yield self.commit()
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_createAddressBookObjectWithName_exists(self):
</span><span class="cx"> """
</span><span class="lines">@@ -808,9 +807,7 @@
</span><span class="cx"> addressbookObject = yield addressbook1.addressbookObjectWithName("1.vcf")
</span><span class="cx"> self.assertEquals((yield addressbookObject.component()), component)
</span><span class="cx">
</span><del>- yield self.commit()
-
- # Make sure notification fired after commit
</del><ins>+ # notify is called prior to commit
</ins><span class="cx"> self.assertEquals(
</span><span class="cx"> set(self.notifierFactory.history),
</span><span class="cx"> set([
</span><span class="lines">@@ -819,7 +816,9 @@
</span><span class="cx"> ])
</span><span class="cx"> )
</span><span class="cx">
</span><ins>+ yield self.commit()
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> def checkPropertiesMethod(self, thunk):
</span><span class="cx"> """
</span><span class="cx"> Verify that the given object has a properties method that returns an
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorefilepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/file.py (11816 => 11817)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/file.py        2013-10-15 17:00:57 UTC (rev 11816)
+++ CalendarServer/trunk/txdav/common/datastore/file.py        2013-10-15 23:24:11 UTC (rev 11817)
</span><span class="lines">@@ -926,6 +926,7 @@
</span><span class="cx"> return (self._notifierPrefix, self.uid(),)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @inlineCallbacks
</ins><span class="cx"> def notifyChanged(self):
</span><span class="cx"> """
</span><span class="cx"> Trigger a notification of a change
</span><span class="lines">@@ -933,8 +934,14 @@
</span><span class="cx">
</span><span class="cx"> # Only send one set of change notifications per transaction
</span><span class="cx"> if self._notifiers and not self._transaction.isNotifiedAlready(self):
</span><del>- for notifier in self._notifiers.values():
</del><ins>+ # cache notifiers run in post commit
+ notifier = self._notifiers.get("cache", None)
+ if notifier:
</ins><span class="cx"> self._transaction.postCommit(notifier.notify)
</span><ins>+ # push notifiers add their work items immediately
+ notifier = self._notifiers.get("push", None)
+ if notifier:
+ yield notifier.notify(self._transaction)
</ins><span class="cx"> self._transaction.notificationAddedForObject(self)
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1272,6 +1279,7 @@
</span><span class="cx"> return self.ownerHome().notifierID()
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @inlineCallbacks
</ins><span class="cx"> def notifyChanged(self):
</span><span class="cx"> """
</span><span class="cx"> Trigger a notification of a change
</span><span class="lines">@@ -1279,8 +1287,14 @@
</span><span class="cx">
</span><span class="cx"> # Only send one set of change notifications per transaction
</span><span class="cx"> if self._notifiers and not self._transaction.isNotifiedAlready(self):
</span><del>- for notifier in self._notifiers.values():
</del><ins>+ # cache notifiers run in post commit
+ notifier = self._notifiers.get("cache", None)
+ if notifier:
</ins><span class="cx"> self._transaction.postCommit(notifier.notify)
</span><ins>+ # push notifiers add their work items immediately
+ notifier = self._notifiers.get("push", None)
+ if notifier:
+ yield notifier.notify(self._transaction)
</ins><span class="cx"> self._transaction.notificationAddedForObject(self)
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql.py (11816 => 11817)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql.py        2013-10-15 17:00:57 UTC (rev 11816)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py        2013-10-15 23:24:11 UTC (rev 11817)
</span><span class="lines">@@ -2197,6 +2197,7 @@
</span><span class="cx"> the resource has changed. We ensure we only do this once per object
</span><span class="cx"> per transaction.
</span><span class="cx"> """
</span><ins>+
</ins><span class="cx"> if self._txn.isNotifiedAlready(self):
</span><span class="cx"> returnValue(None)
</span><span class="cx"> self._txn.notificationAddedForObject(self)
</span><span class="lines">@@ -2207,8 +2208,14 @@
</span><span class="cx">
</span><span class="cx"> # Send notifications
</span><span class="cx"> if self._notifiers:
</span><del>- for notifier in self._notifiers.values():
</del><ins>+ # cache notifiers run in post commit
+ notifier = self._notifiers.get("cache", None)
+ if notifier:
</ins><span class="cx"> self._txn.postCommit(notifier.notify)
</span><ins>+ # push notifiers add their work items immediately
+ notifier = self._notifiers.get("push", None)
+ if notifier:
+ yield notifier.notify(self._txn)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @classproperty
</span><span class="lines">@@ -4261,8 +4268,14 @@
</span><span class="cx">
</span><span class="cx"> # Send notifications
</span><span class="cx"> if self._notifiers:
</span><del>- for notifier in self._notifiers.values():
</del><ins>+ # cache notifiers run in post commit
+ notifier = self._notifiers.get("cache", None)
+ if notifier:
</ins><span class="cx"> self._txn.postCommit(notifier.notify)
</span><ins>+ # push notifiers add their work items immediately
+ notifier = self._notifiers.get("push", None)
+ if notifier:
+ yield notifier.notify(self._txn)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @classproperty
</span><span class="lines">@@ -5082,15 +5095,21 @@
</span><span class="cx"> the resource has changed. We ensure we only do this once per object
</span><span class="cx"> per transaction.
</span><span class="cx"> """
</span><del>- yield
</del><span class="cx"> if self._txn.isNotifiedAlready(self):
</span><span class="cx"> returnValue(None)
</span><span class="cx"> self._txn.notificationAddedForObject(self)
</span><span class="cx">
</span><span class="cx"> # Send notifications
</span><span class="cx"> if self._notifiers:
</span><del>- for notifier in self._notifiers.values():
</del><ins>+ # cache notifiers run in post commit
+ notifier = self._notifiers.get("cache", None)
+ if notifier:
</ins><span class="cx"> self._txn.postCommit(notifier.notify)
</span><ins>+ # push notifiers add their work items immediately
+ notifier = self._notifiers.get("push", None)
+ if notifier:
+ yield notifier.notify(self._txn)
+
</ins><span class="cx"> returnValue(None)
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoretestutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/test/util.py (11816 => 11817)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/test/util.py        2013-10-15 17:00:57 UTC (rev 11816)
+++ CalendarServer/trunk/txdav/common/datastore/test/util.py        2013-10-15 23:24:11 UTC (rev 11817)
</span><span class="lines">@@ -726,7 +726,7 @@
</span><span class="cx"> return "/%s/%s/%s/" % (prefix, self.hostname, id)
</span><span class="cx">
</span><span class="cx">
</span><del>- def send(self, prefix, id):
</del><ins>+ def send(self, prefix, id, txn):
</ins><span class="cx"> self.history.append(self.pushKeyForId(prefix, id))
</span><span class="cx">
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>