[CalendarServer-changes] [5873] CalendarServer/branches/new-store
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jul 12 16:12:59 PDT 2010
Revision: 5873
http://trac.macosforge.org/projects/calendarserver/changeset/5873
Author: glyph at apple.com
Date: 2010-07-12 16:12:58 -0700 (Mon, 12 Jul 2010)
Log Message:
-----------
add correct etag and correct contentType read calls into the back-end so that listing attachments is possible
Modified Paths:
--------------
CalendarServer/branches/new-store/twistedcaldav/storebridge.py
CalendarServer/branches/new-store/txcaldav/calendarstore/file.py
Modified: CalendarServer/branches/new-store/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/new-store/twistedcaldav/storebridge.py 2010-07-12 15:54:47 UTC (rev 5872)
+++ CalendarServer/branches/new-store/twistedcaldav/storebridge.py 2010-07-12 23:12:58 UTC (rev 5873)
@@ -31,7 +31,7 @@
from twext.python.filepath import CachingFilePath as FilePath
from twext.python.log import Logger
-from twext.web2.http_headers import ETag
+from twext.web2.http_headers import ETag, MimeType
from twext.web2.dav.http import ErrorResponse, ResponseQueue
from twext.web2.dav.element.base import dav_namespace
from twext.web2.responsecode import (
@@ -443,8 +443,8 @@
class ProtoCalendarAttachment(_GetChildHelper, CalDAVResource):
- def __init__(self, calendarObject, attachmentName):
- super(ProtoCalendarAttachment, self).__init__()
+ def __init__(self, calendarObject, attachmentName, **kw):
+ super(ProtoCalendarAttachment, self).__init__(**kw)
self.calendarObject = calendarObject
self.attachmentName = attachmentName
@@ -454,7 +454,7 @@
def http_PUT(self, request):
- # FIXME: MIME-Type
+ # FIXME: MIME-Type from header
# FIXME: direct test
# FIXME: transformation?
t = self.calendarObject.createAttachmentWithName(
@@ -475,6 +475,18 @@
self._newStoreAttachment = attachment
+ def etag(self):
+ # FIXME: test
+ md5 = self._newStoreAttachment.md5()
+ return ETag(md5)
+
+
+ def contentType(self):
+ # FIXME: test
+ return MimeType.fromString(
+ self._newStoreAttachment.contentType())
+
+
def getChild(self, name):
return None
@@ -482,7 +494,7 @@
# FIXME: @requiresPermissions(davxml.Write())
def http_PUT(self, request):
# FIXME: direct test
- # FIXME: MIME-Type
+ # FIXME: MIME-Type from header
# FIXME: refactor with ProtoCalendarAttachment.http_PUT
# FIXME: CDT test to make sure that permissions are enforced.
t = self._newStoreAttachment.store("application/octet-stream")
Modified: CalendarServer/branches/new-store/txcaldav/calendarstore/file.py
===================================================================
--- CalendarServer/branches/new-store/txcaldav/calendarstore/file.py 2010-07-12 15:54:47 UTC (rev 5872)
+++ CalendarServer/branches/new-store/txcaldav/calendarstore/file.py 2010-07-12 23:12:58 UTC (rev 5873)
@@ -331,9 +331,6 @@
def attachmentWithName(self, name):
- """
-
- """
# Attachments can be local or remote, but right now we only care about
# local. So we're going to base this on the listing of files in the
# dropbox and not on the calendar data. However, we COULD examine the
@@ -341,7 +338,12 @@
if name in self._attachments:
return self._attachments[name]
- return Attachment(self, name)
+ # FIXME: cache consistently (put it in self._attachments)
+ if self._dropboxPath().child(name).exists():
+ return Attachment(self, name)
+ else:
+ # FIXME: test for non-existent attachment.
+ return None
# But, ahem.
@@ -353,9 +355,6 @@
def dropboxID(self):
- """
-
- """
component = self.component()
for subcomp in self._allSubcomponents(component):
dropboxProperty = subcomp.getProperty("X-APPLE-DROPBOX")
@@ -363,6 +362,9 @@
componentDropboxID = dropboxProperty.value().split("/")[-1]
return componentDropboxID
# FIXME: direct tests
+
+ # FIXME: read ATTACH properties as well as X-APPLE-DROPBOX properties,
+ # since X-APPLE-DROPBOX only appears when others can write attachments.
return self.uid() + ".dropbox"
@@ -444,7 +446,13 @@
def _properties(self):
- # Not exposed
+ """
+ Create and return a private xattr L{PropertyStore} for storing some of
+ the data about this L{Attachment}. This is private because attachments
+ do not (currently) require arbitrary dead property storage, but older
+ servers did store useful information about attachments in xattr
+ properties in the filesystem.
+ """
return PropertyStore(
self._calendarObject._parentCollection._home.peruser_uid(),
self._calendarObject._parentCollection._home.uid(),
@@ -453,7 +461,8 @@
def contentType(self):
- return self._properties()[contentTypeKey].children[0]
+ # FIXME: tests
+ return self._properties()[contentTypeKey].children[0].data
def store(self, contentType):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100712/dc1a8fea/attachment.html>
More information about the calendarserver-changes
mailing list