<!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>[9970] 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/9970">9970</a></dd>
<dt>Author</dt> <dd>glyph@apple.com</dd>
<dt>Date</dt> <dd>2012-10-22 16:11:21 -0700 (Mon, 22 Oct 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Always abort transactions for HTTP requests that end in an exception being raised, even if that exception is an expected HTTPError that indicates some kind of known error.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktwextweb2resourcepy">CalendarServer/trunk/twext/web2/resource.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavmethodmkcalendarpy">CalendarServer/trunk/twistedcaldav/method/mkcalendar.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavmethodmkcolpy">CalendarServer/trunk/twistedcaldav/method/mkcol.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavresourcepy">CalendarServer/trunk/twistedcaldav/resource.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavstorebridgepy">CalendarServer/trunk/twistedcaldav/storebridge.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtesttest_wrappingpy">CalendarServer/trunk/twistedcaldav/test/test_wrapping.py</a></li>
<li><a href="#CalendarServertrunktxdavbasepropertystoresqlpy">CalendarServer/trunk/txdav/base/propertystore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresqlpy">CalendarServer/trunk/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoretesttest_sqlpy">CalendarServer/trunk/txdav/common/datastore/test/test_sql.py</a></li>
</ul>
<h3>Property Changed</h3>
<ul>
<li><a href="#CalendarServertrunk">CalendarServer/trunk/</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunk"></a>
<div class="propset"><h4>Property changes: CalendarServer/trunk</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4>Modified: svn:mergeinfo</h4></div>
<span class="cx">/CalendarServer/branches/egg-info-351:4589-4625
</span><span class="cx">/CalendarServer/branches/generic-sqlstore:6167-6191
</span><span class="cx">/CalendarServer/branches/new-store:5594-5934
</span><span class="cx">/CalendarServer/branches/new-store-no-caldavfile:5911-5935
</span><span class="cx">/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
</span><span class="cx">/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
</span><span class="cx">/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
</span><span class="cx">/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
</span><span class="cx">/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
</span><span class="cx">/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
</span><span class="cx">/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
</span><span class="cx">/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pods:7297-7377
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pycard:7227-7237
</span><span class="cx">/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
</span><span class="cx">/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
</span><span class="cx">/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
</span><span class="cx">/CalendarServer/branches/users/cdaboo/timezones:7443-7699
</span><span class="cx">/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
</span><span class="cx">/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
</span><span class="cx">/CalendarServer/branches/users/glyph/conn-limit:6574-6577
</span><span class="cx">/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
</span><span class="cx">/CalendarServer/branches/users/glyph/dalify:6932-7023
</span><span class="cx">/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
</span><span class="cx">/CalendarServer/branches/users/glyph/deploybuild:7563-7572
</span><span class="cx">/CalendarServer/branches/users/glyph/disable-quota:7718-7727
</span><span class="cx">/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
</span><span class="cx">/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
</span><span class="cx">/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
</span><span class="cx">/CalendarServer/branches/users/glyph/linux-tests:6893-6900
</span><span class="cx">/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
</span><span class="cx">/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
</span><span class="cx">/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
</span><span class="cx">/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
</span><span class="cx">/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
</span><span class="cx">/CalendarServer/branches/users/glyph/new-export:7444-7485
</span><span class="cx">/CalendarServer/branches/users/glyph/oracle:7106-7155
</span><span class="cx">/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
</span><span class="cx">/CalendarServer/branches/users/glyph/other-html:8062-8091
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
</span><span class="cx">/CalendarServer/branches/users/glyph/q:9560-9688
</span><span class="cx">/CalendarServer/branches/users/glyph/quota:7604-7637
</span><span class="cx">/CalendarServer/branches/users/glyph/sendfdport:5388-5424
</span><span class="cx">/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
</span><span class="cx">/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
</span><span class="cx">/CalendarServer/branches/users/glyph/sharedpool:6490-6550
</span><span class="cx">/CalendarServer/branches/users/glyph/sharing-api:9192-9205
</span><span class="cx">/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
</span><span class="cx">/CalendarServer/branches/users/glyph/sql-store:5929-6073
</span><span class="cx">/CalendarServer/branches/users/glyph/subtransactions:7248-7258
</span><span class="cx">/CalendarServer/branches/users/glyph/table-alias:8651-8664
</span><span class="cx">/CalendarServer/branches/users/glyph/uidexport:7673-7676
</span><span class="cx">/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
</span><span class="cx">/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
</span><span class="cx">/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
</span><span class="cx">/CalendarServer/branches/users/sagen/applepush:8126-8184
</span><span class="cx">/CalendarServer/branches/users/sagen/inboxitems:7380-7381
</span><span class="cx">/CalendarServer/branches/users/sagen/locations-resources:5032-5051
</span><span class="cx">/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
</span><span class="cx">/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
</span><span class="cx">/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
</span><span class="cx">/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
</span><span class="cx">/CalendarServer/branches/users/sagen/resources-2:5084-5093
</span><span class="cx">/CalendarServer/branches/users/wsanchez/transations:5515-5593
</span><span class="cx"> + /CalendarServer/branches/config-separation:4379-4443
</span><span class="cx">/CalendarServer/branches/egg-info-351:4589-4625
</span><span class="cx">/CalendarServer/branches/generic-sqlstore:6167-6191
</span><span class="cx">/CalendarServer/branches/new-store:5594-5934
</span><span class="cx">/CalendarServer/branches/new-store-no-caldavfile:5911-5935
</span><span class="cx">/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
</span><span class="cx">/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
</span><span class="cx">/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
</span><span class="cx">/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
</span><span class="cx">/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
</span><span class="cx">/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
</span><span class="cx">/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
</span><span class="cx">/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pods:7297-7377
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pycard:7227-7237
</span><span class="cx">/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
</span><span class="cx">/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
</span><span class="cx">/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
</span><span class="cx">/CalendarServer/branches/users/cdaboo/timezones:7443-7699
</span><span class="cx">/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
</span><span class="cx">/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
</span><span class="cx">/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
</span><span class="cx">/CalendarServer/branches/users/glyph/conn-limit:6574-6577
</span><span class="cx">/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
</span><span class="cx">/CalendarServer/branches/users/glyph/dalify:6932-7023
</span><span class="cx">/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
</span><span class="cx">/CalendarServer/branches/users/glyph/deploybuild:7563-7572
</span><span class="cx">/CalendarServer/branches/users/glyph/disable-quota:7718-7727
</span><span class="cx">/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
</span><span class="cx">/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
</span><span class="cx">/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
</span><span class="cx">/CalendarServer/branches/users/glyph/linux-tests:6893-6900
</span><span class="cx">/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
</span><span class="cx">/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
</span><span class="cx">/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
</span><span class="cx">/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
</span><span class="cx">/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
</span><span class="cx">/CalendarServer/branches/users/glyph/new-export:7444-7485
</span><span class="cx">/CalendarServer/branches/users/glyph/oracle:7106-7155
</span><span class="cx">/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
</span><span class="cx">/CalendarServer/branches/users/glyph/other-html:8062-8091
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
</span><span class="cx">/CalendarServer/branches/users/glyph/q:9560-9688
</span><span class="cx">/CalendarServer/branches/users/glyph/quota:7604-7637
</span><span class="cx">/CalendarServer/branches/users/glyph/sendfdport:5388-5424
</span><span class="cx">/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
</span><span class="cx">/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
</span><span class="cx">/CalendarServer/branches/users/glyph/sharedpool:6490-6550
</span><span class="cx">/CalendarServer/branches/users/glyph/sharing-api:9192-9205
</span><span class="cx">/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
</span><span class="cx">/CalendarServer/branches/users/glyph/sql-store:5929-6073
</span><span class="cx">/CalendarServer/branches/users/glyph/subtransactions:7248-7258
</span><span class="cx">/CalendarServer/branches/users/glyph/table-alias:8651-8664
</span><span class="cx">/CalendarServer/branches/users/glyph/uidexport:7673-7676
</span><span class="cx">/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
</span><span class="cx">/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
</span><span class="cx">/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
</span><span class="cx">/CalendarServer/branches/users/sagen/applepush:8126-8184
</span><span class="cx">/CalendarServer/branches/users/sagen/inboxitems:7380-7381
</span><span class="cx">/CalendarServer/branches/users/sagen/locations-resources:5032-5051
</span><span class="cx">/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
</span><span class="cx">/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
</span><span class="cx">/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
</span><span class="cx">/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
</span><span class="cx">/CalendarServer/branches/users/sagen/resources-2:5084-5093
</span><span class="cx">/CalendarServer/branches/users/wsanchez/transations:5515-5593
</span><a id="CalendarServertrunktwextweb2resourcepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/web2/resource.py (9969 => 9970)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/web2/resource.py        2012-10-22 23:09:18 UTC (rev 9969)
+++ CalendarServer/trunk/twext/web2/resource.py        2012-10-22 23:11:21 UTC (rev 9970)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx">
</span><span class="cx"> from twext.web2 import iweb, http, server, responsecode
</span><span class="cx">
</span><ins>+from twisted.internet.defer import maybeDeferred
</ins><span class="cx"> class RenderMixin(object):
</span><span class="cx"> """
</span><span class="cx"> Mix-in class for L{iweb.IResource} which provides a dispatch mechanism for
</span><span class="lines">@@ -106,9 +107,20 @@
</span><span class="cx"> returnValue(response)
</span><span class="cx">
</span><span class="cx"> yield self.checkPreconditions(request)
</span><del>- returnValue((yield method(request)))
</del><ins>+ result = maybeDeferred(method, request)
+ result.addErrback(self.methodRaisedException)
+ returnValue((yield result))
</ins><span class="cx">
</span><span class="cx">
</span><ins>+ def methodRaisedException(self, failure):
+ """
+ An C{http_METHOD} method raised an exception; this is an errback for
+ that exception. By default, simply propagate the error up; subclasses
+ may override this for top-level exception handling.
+ """
+ return failure
+
+
</ins><span class="cx"> def http_OPTIONS(self, request):
</span><span class="cx"> """
</span><span class="cx"> Respond to a OPTIONS request.
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavmethodmkcalendarpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/method/mkcalendar.py (9969 => 9970)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/method/mkcalendar.py        2012-10-22 23:09:18 UTC (rev 9969)
+++ CalendarServer/trunk/twistedcaldav/method/mkcalendar.py        2012-10-22 23:11:21 UTC (rev 9970)
</span><span class="lines">@@ -106,7 +106,6 @@
</span><span class="cx">
</span><span class="cx"> if got_an_error:
</span><span class="cx"> # Force a transaction error and proper clean-up
</span><del>- self.transactionError()
</del><span class="cx"> errors.error()
</span><span class="cx"> raise HTTPError(MultiStatusResponse([errors.response()]))
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavmethodmkcolpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/method/mkcol.py (9969 => 9970)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/method/mkcol.py        2012-10-22 23:09:18 UTC (rev 9969)
+++ CalendarServer/trunk/twistedcaldav/method/mkcol.py        2012-10-22 23:11:21 UTC (rev 9970)
</span><span class="lines">@@ -182,7 +182,6 @@
</span><span class="cx">
</span><span class="cx"> if got_an_error:
</span><span class="cx"> # Clean up
</span><del>- self.transactionError()
</del><span class="cx"> errors.error()
</span><span class="cx"> raise HTTPError(Response(
</span><span class="cx"> code=responsecode.FORBIDDEN,
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavresourcepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/resource.py (9969 => 9970)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/resource.py        2012-10-22 23:09:18 UTC (rev 9969)
+++ CalendarServer/trunk/twistedcaldav/resource.py        2012-10-22 23:11:21 UTC (rev 9970)
</span><span class="lines">@@ -318,8 +318,14 @@
</span><span class="cx"> otherResource.associateWithTransaction(self._associatedTransaction)
</span><span class="cx">
</span><span class="cx">
</span><del>- def transactionError(self):
</del><ins>+ def methodRaisedException(self, failure):
+ """
+ An C{http_METHOD} method raised an exception. Any type of exception,
+ including those that result in perfectly valid HTTP responses, should
+ abort the transaction.
+ """
</ins><span class="cx"> self._transactionError = True
</span><ins>+ return super(CalDAVResource, self).methodRaisedException(failure)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavstorebridgepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/storebridge.py (9969 => 9970)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/storebridge.py        2012-10-22 23:09:18 UTC (rev 9969)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py        2012-10-22 23:11:21 UTC (rev 9970)
</span><span class="lines">@@ -1611,8 +1611,6 @@
</span><span class="cx"> yield readStream(request.stream, t.write)
</span><span class="cx"> except Exception, e:
</span><span class="cx"> log.error("Unable to store attachment: %s" % (e,))
</span><del>- # Signal to abort in twistedcaldav.resource.CalDAVResource.RenderHTTP
- self.transactionError()
</del><span class="cx"> raise HTTPError(SERVICE_UNAVAILABLE)
</span><span class="cx">
</span><span class="cx"> try:
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtesttest_wrappingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/test/test_wrapping.py (9969 => 9970)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/test/test_wrapping.py        2012-10-22 23:09:18 UTC (rev 9969)
+++ CalendarServer/trunk/twistedcaldav/test/test_wrapping.py        2012-10-22 23:11:21 UTC (rev 9970)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> from twistedcaldav.directory.test.test_xmlfile import XMLFileBase
</span><span class="cx"> from txdav.caldav.icalendarstore import ICalendarHome
</span><span class="cx"> from txdav.carddav.iaddressbookstore import IAddressBookHome
</span><ins>+
</ins><span class="cx"> from txdav.caldav.datastore.file import Calendar
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -108,6 +109,7 @@
</span><span class="cx">
</span><span class="cx"> @param objectName: The name of a calendar object.
</span><span class="cx"> @type objectName: str
</span><ins>+
</ins><span class="cx"> @param objectText: Some iCalendar text to populate it with.
</span><span class="cx"> @type objectText: str
</span><span class="cx"> """
</span><span class="lines">@@ -167,7 +169,6 @@
</span><span class="cx">
</span><span class="cx"> @param path: the path from the root of the site (not starting with a
</span><span class="cx"> slash)
</span><del>-
</del><span class="cx"> @type path: C{str}
</span><span class="cx">
</span><span class="cx"> @param method: the HTTP method to initialize the request with.
</span><span class="lines">@@ -266,8 +267,8 @@
</span><span class="cx">
</span><span class="cx"> def test_createStore(self):
</span><span class="cx"> """
</span><del>- Creating a DirectoryCalendarHomeProvisioningResource will create a paired
- CalendarStore.
</del><ins>+ Creating a DirectoryCalendarHomeProvisioningResource will create a
+ paired CalendarStore.
</ins><span class="cx"> """
</span><span class="cx"> assertProvides(self, IDataStore, self.calendarCollection._newStore)
</span><span class="cx">
</span><span class="lines">@@ -518,7 +519,20 @@
</span><span class="cx"> frozenset([self.principalsResource]))
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @inlineCallbacks
+ def assertCalendarEmpty(self, user, calendarName="calendar"):
+ """
+ Assert that a user's calendar is empty (their default calendar by default).
+ """
+ txn = self.calendarStore.newTransaction()
+ self.addCleanup(txn.commit)
+ home = yield txn.calendarHomeWithUID(user, create=True)
+ cal = yield home.calendarWithName(calendarName)
+ objects = yield cal.calendarObjects()
+ self.assertEquals(len(objects), 0)
</ins><span class="cx">
</span><ins>+
+
</ins><span class="cx"> class DatabaseWrappingTests(WrappingTests):
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -531,4 +545,73 @@
</span><span class="cx"> return self.calendarStore
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @inlineCallbacks
+ def test_invalidCalendarPUT(self):
+ """
+ Exceeding quota on an attachment returns an HTTP error code.
+ """
+ # yield self.populateOneObject("1.ics", test_event_text)
+ @inlineCallbacks
+ def putEvt(txt):
+ calendarObject = yield self.getResource(
+ "/calendars/users/wsanchez/calendar/1.ics",
+ "PUT", "wsanchez"
+ )
+ self.requestUnderTest.stream = MemoryStream(txt)
+ returnValue(
+ ((yield calendarObject.renderHTTP(self.requestUnderTest)),
+ self.requestUnderTest)
+ )
+ # see twistedcaldav/directory/test/accounts.xml
+ wsanchez = '6423F94A-6B76-4A3A-815B-D52CFD77935D'
+ cdaboo = '5A985493-EE2C-4665-94CF-4DFEA3A89500'
+ eventTemplate="""\
+BEGIN:VCALENDAR
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+VERSION:2.0
+BEGIN:VEVENT
+UID:20060110T231240Z-4011c71-187-6f73
+ORGANIZER:urn:uuid:{wsanchez}
+ATTENDEE:urn:uuid:{wsanchez}
+DTSTART:20110101T050000Z
+DTSTAMP:20110309T185105Z
+DURATION:PT1H
+SUMMARY:Test
+RRULE:FREQ=DAILY;COUNT=2
+END:VEVENT
+BEGIN:VEVENT
+UID:20060110T231240Z-4011c71-187-6f73
+RECURRENCE-ID:20110102T050000Z
+ORGANIZER:urn:uuid:{wsanchez}
+ATTENDEE:urn:uuid:{wsanchez}
+ATTENDEE:urn:uuid:{cdaboo}
+DTSTART:20110102T050000Z
+DTSTAMP:20110309T185105Z
+DURATION:PT1H
+SUMMARY:Test
+END:VEVENT{0}
+END:VCALENDAR
+"""
+ CR = "\n"
+ CRLF = "\r\n"
+ #validEvent = eventTemplate.format("", wsanchez=wsanchez, cdaboo=cdaboo).replace(CR, CRLF)
+ invalidInstance = """
+BEGIN:VEVENT
+UID:20060110T231240Z-4011c71-187-6f73
+RECURRENCE-ID:20110110T050000Z
+ORGANIZER:urn:uuid:{wsanchez}
+ATTENDEE:urn:uuid:{wsanchez}
+DTSTART:20110110T050000Z
+DTSTAMP:20110309T185105Z
+DURATION:PT1H
+SUMMARY:Test
+END:VEVENT""".format(wsanchez=wsanchez, cdaboo=cdaboo)
+ #txn = self.requestUnderTest._newStoreTransaction
+ invalidEvent = eventTemplate.format(invalidInstance, wsanchez=wsanchez, cdaboo=cdaboo).replace(CR, CRLF)
+ resp2, rsrc2 = yield putEvt(invalidEvent)
+ self.requestUnderTest = None
+ yield self.assertCalendarEmpty(wsanchez)
+ yield self.assertCalendarEmpty(cdaboo)
</ins><span class="cx">
</span><ins>+
</ins></span></pre></div>
<a id="CalendarServertrunktxdavbasepropertystoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/base/propertystore/sql.py (9969 => 9970)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/base/propertystore/sql.py        2012-10-22 23:09:18 UTC (rev 9969)
+++ CalendarServer/trunk/txdav/base/propertystore/sql.py        2012-10-22 23:11:21 UTC (rev 9970)
</span><span class="lines">@@ -30,6 +30,8 @@
</span><span class="cx"> Select, Parameter, Update, Insert, TableSyntax, Delete)
</span><span class="cx">
</span><span class="cx"> from txdav.xml.parser import WebDAVDocument
</span><ins>+from txdav.common.icommondatastore import AllRetriesFailed
+from twext.python.log import LoggingMixIn
</ins><span class="cx"> from txdav.common.datastore.sql_tables import schema
</span><span class="cx"> from txdav.base.propertystore.base import (AbstractPropertyStore,
</span><span class="cx"> PropertyName, validKey)
</span><span class="lines">@@ -39,7 +41,7 @@
</span><span class="cx">
</span><span class="cx"> prop = schema.RESOURCE_PROPERTY
</span><span class="cx">
</span><del>-class PropertyStore(AbstractPropertyStore):
</del><ins>+class PropertyStore(AbstractPropertyStore, LoggingMixIn):
</ins><span class="cx">
</span><span class="cx"> _cacher = Memcacher("SQL.props", pickle=True, key_normalization=False)
</span><span class="cx">
</span><span class="lines">@@ -255,7 +257,10 @@
</span><span class="cx"> if hasattr(self, "_notifyCallback") and self._notifyCallback is not None:
</span><span class="cx"> self._notifyCallback()
</span><span class="cx">
</span><del>- self._txn.subtransaction(trySetItem)
</del><ins>+ def justLogIt(f):
+ f.trap(AllRetriesFailed)
+ self.log_error("setting a property failed; probably nothing.")
+ self._txn.subtransaction(trySetItem).addErrback(justLogIt)
</ins><span class="cx">
</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 (9969 => 9970)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql.py        2012-10-22 23:09:18 UTC (rev 9969)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py        2012-10-22 23:11:21 UTC (rev 9970)
</span><span class="lines">@@ -751,6 +751,13 @@
</span><span class="cx"> block = self._sqlTxn.commandBlock()
</span><span class="cx"> sp = self._savepoint()
</span><span class="cx"> failuresToMaybeLog = []
</span><ins>+ def end():
+ block.end()
+ for f in failuresToMaybeLog:
+ # TODO: direct tests, to make sure error logging
+ # happens correctly in all cases.
+ log.err(f)
+ raise AllRetriesFailed()
</ins><span class="cx"> triesLeft = retries
</span><span class="cx"> try:
</span><span class="cx"> while True:
</span><span class="lines">@@ -758,8 +765,9 @@
</span><span class="cx"> try:
</span><span class="cx"> result = yield thunk(block)
</span><span class="cx"> except:
</span><ins>+ f = Failure()
</ins><span class="cx"> if not failureOK:
</span><del>- failuresToMaybeLog.append(Failure())
</del><ins>+ failuresToMaybeLog.append(f)
</ins><span class="cx"> yield sp.rollback(block)
</span><span class="cx"> if triesLeft:
</span><span class="cx"> triesLeft -= 1
</span><span class="lines">@@ -774,12 +782,7 @@
</span><span class="cx"> block = newBlock
</span><span class="cx"> sp = self._savepoint()
</span><span class="cx"> else:
</span><del>- block.end()
- for f in failuresToMaybeLog:
- # TODO: direct tests, to make sure error logging
- # happens correctly in all cases.
- log.err(f)
- raise AllRetriesFailed()
</del><ins>+ end()
</ins><span class="cx"> else:
</span><span class="cx"> yield sp.release(block)
</span><span class="cx"> block.end()
</span><span class="lines">@@ -790,9 +793,10 @@
</span><span class="cx"> # and only that case - acquire() or release() or commandBlock() may
</span><span class="cx"> # raise an AlreadyFinishedError (either synchronously, or in the
</span><span class="cx"> # case of the first two, possibly asynchronously as well). We can
</span><del>- # safely ignore this, because it can't have any real effect; our
- # caller shouldn't be paying attention anyway.
- block.end()
</del><ins>+ # safely ignore this error, because it can't have any effect on what
+ # gets written; our caller will just get told that it failed in a
+ # way they have to be prepared for anyway.
+ end()
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoretesttest_sqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/test/test_sql.py (9969 => 9970)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/test/test_sql.py        2012-10-22 23:09:18 UTC (rev 9969)
+++ CalendarServer/trunk/txdav/common/datastore/test/test_sql.py        2012-10-22 23:11:21 UTC (rev 9970)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="cx"> from twisted.internet.task import Clock
</span><span class="cx"> from twisted.trial.unittest import TestCase
</span><ins>+from twisted.internet.defer import Deferred
</ins><span class="cx">
</span><span class="cx"> from txdav.common.datastore.sql import log, CommonStoreTransactionMonitor,\
</span><span class="cx"> CommonHome, CommonHomeChild, ECALENDARTYPE
</span><span class="lines">@@ -227,7 +228,8 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_subtransactionFailSomeRetries(self):
</span><span class="cx"> """
</span><del>- txn.subtransaction runs loop three times when all fail and two retries requested.
</del><ins>+ txn.subtransaction runs loop three times when all fail and two retries
+ requested.
</ins><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> txn = self.transactionUnderTest()
</span><span class="lines">@@ -251,7 +253,35 @@
</span><span class="cx"> self.fail("AllRetriesFailed not raised")
</span><span class="cx"> self.assertEqual(ctr[0], 3)
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> @inlineCallbacks
</span><ins>+ def test_subtransactionAbortOuterTransaction(self):
+ """
+ If an outer transaction that is holding a subtransaction open is
+ aborted, then the L{Deferred} returned by L{subtransaction} raises
+ L{AllRetriesFailed}.
+ """
+ txn = self.transactionUnderTest()
+ cs = schema.CALENDARSERVER
+ waitAMoment = Deferred()
+ @inlineCallbacks
+ def later(subtxn):
+ yield waitAMoment
+ value = yield Select([cs.VALUE], From=cs).on(subtxn)
+ returnValue(value)
+ started = txn.subtransaction(later)
+ txn.abort()
+ waitAMoment.callback(True)
+ try:
+ result = yield started
+ except AllRetriesFailed:
+ pass
+ else:
+ self.fail("AllRetriesFailed not raised, %r returned instead" %
+ (result,))
+
+
+ @inlineCallbacks
</ins><span class="cx"> def test_changeRevision(self):
</span><span class="cx"> """
</span><span class="cx"> CommonHomeChild._changeRevision actions.
</span></span></pre>
</div>
</div>
</body>
</html>