[CalendarServer-changes] [305]
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Thu Oct 26 09:12:56 PDT 2006
Revision: 305
http://trac.macosforge.org/projects/calendarserver/changeset/305
Author: cdaboo at apple.com
Date: 2006-10-26 09:12:56 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Handle creation of drop boxes in drop box home by setting appropriate resourcetype and ensuring that
ACLs on the drop box are always inheritable.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/__init__.py
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/dropbox.py
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/mkcol.py
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/resource.py
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/__init__.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/__init__.py 2006-10-26 16:02:36 UTC (rev 304)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/__init__.py 2006-10-26 16:12:56 UTC (rev 305)
@@ -30,6 +30,7 @@
"dateops",
"db",
"directory",
+ "dropbox",
"ical",
"index",
"instance",
@@ -48,5 +49,7 @@
import twisted.web2.dav.davxml
import twistedcaldav.caldavxml
+import twistedcaldav.customxml
twisted.web2.dav.davxml.registerElements(twistedcaldav.caldavxml)
+twisted.web2.dav.davxml.registerElements(twistedcaldav.customxml)
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py 2006-10-26 16:02:36 UTC (rev 304)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py 2006-10-26 16:12:56 UTC (rev 305)
@@ -25,7 +25,6 @@
change.
"""
-from twisted.web2.dav.element import parser
from twisted.web2.dav.resource import twisted_dav_namespace
from twisted.web2.dav import davxml
@@ -40,8 +39,6 @@
def getValue(self):
return str(self)
-parser.registerElement(TwistedGUIDProperty)
-
class TwistedLastModifiedProperty (davxml.WebDAVTextElement):
"""
Contains the Last-Modified value for a directory record corresponding to a principal.
@@ -53,8 +50,6 @@
def getValue(self):
return str(self)
-parser.registerElement(TwistedLastModifiedProperty)
-
class TwistedCalendarPrincipalURI(davxml.WebDAVTextElement):
"""
Contains the calendarPrincipalURI value for a directory record corresponding to a principal.
@@ -66,8 +61,6 @@
def getValue(self):
return str(self)
-parser.registerElement(TwistedCalendarPrincipalURI)
-
class TwistedGroupMemberGUIDs(davxml.WebDAVElement):
"""
Contains a list of GUIDs (TwistedGUIDProperty) for members of a group. Only used on group principals.
@@ -78,8 +71,6 @@
allowed_children = { (twisted_dav_namespace, "guid"): (0, None) }
-parser.registerElement(TwistedGroupMemberGUIDs)
-
class TwistedScheduleAutoRespond(davxml.WebDAVEmptyElement):
"""
When set on an Inbox, scheduling requests are automatically handled.
@@ -88,7 +79,13 @@
name = "schedule-auto-respond"
hidden = True
-parser.registerElement(TwistedScheduleAutoRespond)
+class DropBoxHome (davxml.WebDAVEmptyElement):
+ """
+ Denotes a drop box home collection (a collection that will contain drop boxes).
+ (Apple Extension to CalDAV)
+ """
+ namespace = twisted_dav_namespace
+ name = "dropboxhome"
class DropBox (davxml.WebDAVEmptyElement):
"""
@@ -111,6 +108,7 @@
A principal property to indicate the location of the drop box home.
(Apple Extension to CalDAV)
"""
+ namespace = twisted_dav_namespace
name = "drop-box-home-URL"
hidden = True
protected = True
@@ -122,6 +120,7 @@
A principal property to indicate the location of the notification collection.
(Apple Extension to CalDAV)
"""
+ namespace = twisted_dav_namespace
name = "notifications-URL"
hidden = True
protected = True
@@ -132,5 +131,6 @@
# Extensions to davxml.ResourceType
##
+davxml.ResourceType.dropboxhome = davxml.ResourceType(davxml.Collection(), DropBoxHome())
davxml.ResourceType.dropbox = davxml.ResourceType(davxml.Collection(), DropBox())
davxml.ResourceType.notifications = davxml.ResourceType(davxml.Collection(), Notifications())
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/dropbox.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/dropbox.py 2006-10-26 16:02:36 UTC (rev 304)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/dropbox.py 2006-10-26 16:12:56 UTC (rev 305)
@@ -16,17 +16,23 @@
# DRI: Cyrus Daboo, cdaboo at apple.com
##
+"""
+Implements drop-box functionality. A drop box is an external attachment store that provides
+for automatic notification of changes to subscribed users.
+"""
+
+__all__ = [
+ "DropBox",
+]
+
from twisted.web2.dav.resource import twisted_dav_namespace
+
from twistedcaldav.customxml import davxml
from twistedcaldav.resource import CalendarPrincipalResource
from twistedcaldav.static import CalDAVFile
+
import os
-"""
-Implements drop-box functionality. A drop box is an external attachment store that provides
-for automatic notification of changes to subscribed users.
-"""
-
class DropBox(object):
# These are all options that will be set from a .plist configuration file.
@@ -91,7 +97,7 @@
child = CalDAVFile(os.path.join(cuhome[1].fp.path, DropBox.dropboxName))
child_exists = child.exists()
if not child_exists:
- c = child.createSpecialCollection(davxml.ResourceType.dropbox)
+ c = child.createSpecialCollection(davxml.ResourceType.dropboxhome)
assert c.called
c = c.result
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/mkcol.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/mkcol.py 2006-10-26 16:02:36 UTC (rev 304)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/mkcol.py 2006-10-26 16:12:56 UTC (rev 305)
@@ -24,8 +24,11 @@
from twisted.internet.defer import deferredGenerator, waitForDeferred
from twisted.web2 import responsecode
+from twisted.web2.dav import davxml
+from twisted.web2.dav.util import parentForURL
from twisted.web2.http import HTTPError, StatusResponse
+from twistedcaldav import customxml
from twistedcaldav.resource import isPseudoCalendarCollectionResource
def http_MKCOL(self, request):
@@ -43,6 +46,17 @@
d = waitForDeferred(super(CalDAVFile, self).http_MKCOL(request))
yield d
- yield d.getResult()
+ result = d.getResult()
+
+ # Check for drop box creation and give it a special resource type
+ from twistedcaldav.dropbox import DropBox
+ if result == responsecode.CREATED and DropBox.enabled:
+ parent = waitForDeferred(request.locateResource(parentForURL(request.uri)))
+ yield parent
+ parent = parent.getResult()
+ if parent.isSpecialCollection(customxml.DropBoxHome):
+ self.writeDeadProperty(davxml.ResourceType.dropbox)
+
+ yield result
http_MKCOL = deferredGenerator(http_MKCOL)
\ No newline at end of file
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/resource.py 2006-10-26 16:02:36 UTC (rev 304)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/resource.py 2006-10-26 16:12:56 UTC (rev 305)
@@ -379,13 +379,17 @@
"""
Write a new ACL to the resource's property store. We override this for calendar collections
and force all the ACEs to be inheritable so that all calendar object resources within the
- calendar collection have the same privileges unless explicitly overridden.
+ calendar collection have the same privileges unless explicitly overridden. The same applies
+ to drop box collections as we want all resources (attachments) to have the same privileges as
+ the drop box collection.
@param newaces: C{list} of L{ACE} for ACL being set.
"""
# Do this only for regular calendar collections and Inbox/Outbox
- if self.isPseudoCalendarCollection():
+ from twistedcaldav.dropbox import DropBox
+ if self.isPseudoCalendarCollection() or \
+ DropBox.enabled and self.isSpecialCollection(customxml.DropBox):
# Add inheritable option to each ACE in the list
for ace in newaces:
if TwistedACLInheritable() not in ace.children:
@@ -595,6 +599,7 @@
home = ""
for url in self.calendarHomeURLs():
home = joinURL(url, DropBox.dropboxName) + "/"
+ break
return customxml.DropBoxHomeURL(davxml.HRef(home))
if name == "notifications-URL":
@@ -602,6 +607,7 @@
home = ""
for url in self.calendarHomeURLs():
home = joinURL(url, DropBox.notifcationName) + "/"
+ break
return customxml.NotificationsURL(davxml.HRef(home))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061026/9ce1b4fb/attachment.html
More information about the calendarserver-changes
mailing list