[CalendarServer-changes] [6243] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Fri Sep 3 14:10:38 PDT 2010
Revision: 6243
http://trac.macosforge.org/projects/calendarserver/changeset/6243
Author: cdaboo at apple.com
Date: 2010-09-03 14:10:37 -0700 (Fri, 03 Sep 2010)
Log Message:
-----------
Make sure ETag header is returned on a PUT of a dropbox attachment.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/extensions.py
CalendarServer/trunk/twistedcaldav/storebridge.py
Modified: CalendarServer/trunk/twistedcaldav/extensions.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/extensions.py 2010-09-03 21:06:09 UTC (rev 6242)
+++ CalendarServer/trunk/twistedcaldav/extensions.py 2010-09-03 21:10:37 UTC (rev 6243)
@@ -33,18 +33,18 @@
import cgi
import time
-from twisted.internet.defer import succeed, DeferredList
+from twisted.internet.defer import succeed, DeferredList, maybeDeferred
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.cred.error import LoginFailed, UnauthorizedLogin
import twext.web2.server
-from twext.web2 import responsecode
+from twext.web2 import responsecode, iweb, http
from twext.web2.auth.wrapper import UnauthorizedResponse
from twext.web2.http import HTTPError, Response, RedirectResponse
from twext.web2.http import StatusResponse
from twext.web2.http_headers import MimeType
from twext.web2.stream import FileStream
-from twext.web2.static import MetaDataMixin
+from twext.web2.static import MetaDataMixin, StaticRenderMixin
from twext.web2.dav import davxml
from twext.web2.dav.auth import PrincipalCredentials
from twext.web2.dav.davxml import dav_namespace
@@ -696,9 +696,12 @@
class DAVResource (DirectoryPrincipalPropertySearchMixIn,
SudoersMixin, SuperDAVResource, LoggingMixIn,
- DirectoryRenderingMixIn):
+ DirectoryRenderingMixIn, StaticRenderMixin):
"""
Extended L{twext.web2.dav.resource.DAVResource} implementation.
+
+ Note we add StaticRenderMixin as a base class because we need all the etag etc behavior
+ that is currently in static.py but is actually applicable to any type of resource.
"""
http_REPORT = http_REPORT
Modified: CalendarServer/trunk/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/storebridge.py 2010-09-03 21:06:09 UTC (rev 6242)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py 2010-09-03 21:10:37 UTC (rev 6243)
@@ -158,13 +158,16 @@
class _NewStoreFileMetaDataHelper(object):
def name(self):
- return self._newStoreObject.name()
+ return self._newStoreObject.name() if self._newStoreObject is not None else None
def etag(self):
# FIXME: far too slow to be used for real, but I needed something to
# placate the etag computation in the case where the file doesn't exist
# yet (an uncommitted transaction creating this calendar file)
+ if self._newStoreObject is None:
+ return None
+
# FIXME: direct tests
try:
md5 = self._newStoreObject.md5()
@@ -182,19 +185,19 @@
return None
def contentType(self):
- return self._newStoreObject.contentType()
+ return self._newStoreObject.contentType() if self._newStoreObject is not None else None
def contentLength(self):
- return self._newStoreObject.size()
+ return self._newStoreObject.size() if self._newStoreObject is not None else None
def lastModified(self):
- return self._newStoreObject.modified()
+ return self._newStoreObject.modified() if self._newStoreObject is not None else None
def creationDate(self):
- return self._newStoreObject.created()
+ return self._newStoreObject.created() if self._newStoreObject is not None else None
def newStoreProperties(self):
- return self._newStoreObject.properties()
+ return self._newStoreObject.properties() if self._newStoreObject is not None else None
class _CalendarChildHelper(object):
"""
@@ -551,14 +554,14 @@
-class ProtoCalendarAttachment(_GetChildHelper):
+class ProtoCalendarAttachment(_NewStoreFileMetaDataHelper, _GetChildHelper):
def __init__(self, calendarObject, attachmentName, **kw):
super(ProtoCalendarAttachment, self).__init__(**kw)
self.calendarObject = calendarObject
self.attachmentName = attachmentName
+ self._newStoreObject = None
-
def isCollection(self):
return False
@@ -586,6 +589,7 @@
content_type,
)
def done(ignored):
+ self._newStoreObject = self.calendarObject.attachmentWithName(self.attachmentName)
t.loseConnection()
return CREATED
return readStream(request.stream, t.write).addCallback(done)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100903/1444348c/attachment-0001.html>
More information about the calendarserver-changes
mailing list