[CalendarServer-changes] [2559] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jun 16 13:30:12 PDT 2008
Revision: 2559
http://trac.macosforge.org/projects/calendarserver/changeset/2559
Author: dreid at apple.com
Date: 2008-06-16 13:30:11 -0700 (Mon, 16 Jun 2008)
Log Message:
-----------
Deal with trying to cache the first unauthenticated request
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/cache.py
CalendarServer/trunk/twistedcaldav/test/test_cache.py
Modified: CalendarServer/trunk/twistedcaldav/cache.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/cache.py 2008-06-16 20:21:19 UTC (rev 2558)
+++ CalendarServer/trunk/twistedcaldav/cache.py 2008-06-16 20:30:11 UTC (rev 2559)
@@ -105,13 +105,13 @@
def _canonicalizeURIForRequest(self, uri, request):
def _uriNotFound(f):
f.trap(AttributeError)
- return Failure(URINotFoundException(uri))
+ raise URINotFoundException(uri)
try:
return request.locateResource(uri).addCallback(
lambda resrc: resrc.url()).addErrback(_uriNotFound)
except AssertionError:
- return fail(Failure(URINotFoundException(uri)))
+ raise URINotFoundException(uri)
def _getURIs(self, request):
@@ -249,7 +249,7 @@
def _handleExceptions(f):
f.trap(URINotFoundException)
- self.log_debug("Could not locate URI: %r" % f.value)
+ self.log_debug("Could not locate URI: %r" % (f.value,))
return None
d = self._hashedRequestKey(request)
@@ -281,6 +281,11 @@
d1.addCallback(_makeCacheEntry, (key, responseBody))
return d1
+ def _handleExceptions(f):
+ f.trap(URINotFoundException)
+ self.log_debug("Could not locate URI: %r" % (f.value,))
+ return response
+
if hasattr(request, 'cacheKey'):
d = succeed(request.cacheKey)
else:
@@ -288,6 +293,7 @@
d.addCallback(self._getResponseBody, response)
d.addCallback(_cacheResponse)
+ d.addErrback(_handleExceptions)
return d
Modified: CalendarServer/trunk/twistedcaldav/test/test_cache.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_cache.py 2008-06-16 20:21:19 UTC (rev 2558)
+++ CalendarServer/trunk/twistedcaldav/test/test_cache.py 2008-06-16 20:30:11 UTC (rev 2559)
@@ -265,7 +265,28 @@
'{DAV:}unauthenticated',
body='bazbax'))
+ d.addCallback(self.assertEquals, None)
+ return d
+
+ def test_cacheUnauthenticatedResponse(self):
+ expected_response = StubResponse(401, {}, "foobar")
+
+ d = self.rc.cacheResponseForRequest(
+ StubRequest('PROPFIND',
+ '/calendars/__uids__/cdaboo/',
+ '{DAV:}unauthenticated'),
+ expected_response)
+
+ d.addCallback(self.assertResponse,
+ (expected_response.code,
+ expected_response.headers,
+ expected_response.body))
+
+ return d
+
+
+
def test_cacheResponseForRequest(self):
expected_response = StubResponse(200, {}, "Foobar")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080616/5f3f955d/attachment.htm
More information about the calendarserver-changes
mailing list