[CalendarServer-changes] [300] CalendarServer/branches/users/cdaboo/dropbox

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 25 12:40:01 PDT 2006


Revision: 300
          http://trac.macosforge.org/projects/calendarserver/changeset/300
Author:   cdaboo at apple.com
Date:     2006-10-25 12:40:00 -0700 (Wed, 25 Oct 2006)

Log Message:
-----------
Drop box options added to .plist file. Plus some new APIs for testing special collection types.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/dropbox/bin/caldavd
    CalendarServer/branches/users/cdaboo/dropbox/conf/caldavd-dev.plist
    CalendarServer/branches/users/cdaboo/dropbox/conf/caldavd.plist
    CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py
    CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/dropbox.py
    CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/icaldav.py
    CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/repository.py
    CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/resource.py

Modified: CalendarServer/branches/users/cdaboo/dropbox/bin/caldavd
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/bin/caldavd	2006-10-25 19:31:21 UTC (rev 299)
+++ CalendarServer/branches/users/cdaboo/dropbox/bin/caldavd	2006-10-25 19:40:00 UTC (rev 300)
@@ -65,6 +65,12 @@
         self.certfile = "/etc/certificates/Default.crt"
         self.manhole = 0
 
+        self.dropbox = True
+        self.dropboxName = "dropbox"
+        self.dropboxACLs = True
+        self.notifications = False
+        self.notifcationName = "notifications"
+
         self.serverlogfile = "/var/log/caldavd/server.log"
         self.errorlogfile = "/var/log/caldavd/error.log"
         self.pidfile = "/var/run/caldavd.pid"
@@ -96,6 +102,11 @@
         print "Only Use SSL:                     %s" % (self.onlyssl,)
         print "SSL Private Key File:             %s" % (self.keyfile,)
         print "SSL Certificate File:             %s" % (self.certfile,)
+        print "Drop Box Enabled:                 %s" % (self.dropbox,)
+        print "Drop Box Name:                    %s" % (self.dropboxName,)
+        print "Drop Box ACLs are Inherited       %s" % (self.dropboxACLs,)
+        print "Notifications Enabled:            %s" % (self.notifications,)
+        print "Notification Collection Name:     %s" % (self.notifcationName,)
         print "Server Log File:                  %s" % (self.serverlogfile,)
         print "Error Log File:                   %s" % (self.errorlogfile,)
         print "PID File:                         %s" % (self.pidfile,)
@@ -259,6 +270,8 @@
         self.action = args[0]
     
     def parsePlist(self):
+    	print "Reading configuration file %s." % (self.plistfile,)
+
         root = readPlist(self.plistfile)
         
         # dict that maps between plist keys and class attributes
@@ -273,6 +286,11 @@
                    "SSLPrivateKey":              "keyfile",
                    "SSLCertificate":             "certfile",
                    "ManholePort":                "manhole",
+                   "DropBoxEnabled":             "dropbox",
+                   "DropBoxName":                "dropboxName",
+                   "DropBoxInheritedACLs":       "dropboxACLs",
+                   "NotificationsEnabled":       "notifications",
+                   "NotificationCollectionName": "notifcationName",
                    "ServerLogFile":              "serverlogfile",
                    "ErrorLogFile":               "errorlogfile",
                    "PIDFile":                    "pidfile",
@@ -336,40 +354,69 @@
     
     def generateTAC(self):
         return """
-docroot       = "%(docroot)s"
-repo          = "%(repo)s"
-doacct        =  %(doacct)s
-doacl         =  %(doacl)s
-dossl         =  %(dossl)s
-keyfile       = "%(keyfile)s"
-certfile      = "%(certfile)s"
-onlyssl       =  %(onlyssl)s
-port          =  %(port)d
-sslport       =  %(sslport)d
-maxsize       =  %(maxsize)d
-quota         =  %(quota)d
-serverlogfile = "%(serverlogfile)s"
-manhole       =  %(manhole)d
+docroot         = "%(docroot)s"
+repo            = "%(repo)s"
+doacct          =  %(doacct)s
+doacl           =  %(doacl)s
+dossl           =  %(dossl)s
+keyfile         = "%(keyfile)s"
+certfile        = "%(certfile)s"
+onlyssl         =  %(onlyssl)s
+port            =  %(port)d
+sslport         =  %(sslport)d
+maxsize         =  %(maxsize)d
+quota           =  %(quota)d
+serverlogfile   = "%(serverlogfile)s"
+dropbox         = "%(dropbox)s"
+dropboxName     = "%(dropboxName)s"
+dropboxACLs     = "%(dropboxACLs)s"
+notifications   = "%(notifications)s"
+notifcationName = "%(notifcationName)s"
+manhole         =  %(manhole)d
 
 from twistedcaldav.repository import startServer
 
-application, site = startServer(docroot, repo, doacct, doacl, dossl, keyfile, certfile, onlyssl, port, sslport, maxsize, quota, serverlogfile, manhole)
+application, site = startServer(docroot,
+                                repo,
+                                doacct,
+                                doacl,
+                                dossl,
+                                keyfile,
+                                certfile,
+                                onlyssl,
+                                port,
+                                sslport,
+                                maxsize,
+                                quota,
+                                serverlogfile,
+                                dropbox,
+                                dropboxName,
+                                dropboxACLs,
+                                notifications,
+                                notifcationName,
+                                manhole)
 
 """ % {
-    "docroot":       self.docroot,
-    "repo":          self.repo,
-    "doacct":        self.doacct,
-    "doacl":         self.doacl,
-    "dossl":         self.dossl,
-    "keyfile":       self.keyfile,
-    "certfile":      self.certfile,
-    "onlyssl":       self.onlyssl,
-    "port":          self.port,
-    "sslport":       self.sslport,
-    "maxsize":       self.maxsize,
-    "quota":         self.quota,
-    "serverlogfile": self.serverlogfile,
-    "manhole":       self.manhole,
+    "docroot":         self.docroot,
+    "repo":            self.repo,
+    "doacct":          self.doacct,
+    "doacl":           self.doacl,
+    "dossl":           self.dossl,
+    "keyfile":         self.keyfile,
+    "certfile":        self.certfile,
+    "onlyssl":         self.onlyssl,
+    "port":            self.port,
+    "sslport":         self.sslport,
+    "maxsize":         self.maxsize,
+    "quota":           self.quota,
+    "serverlogfile":   self.serverlogfile,
+    "dropbox":         self.dropbox,
+    "dropboxName":     self.dropboxName,
+    "dropboxACLs":     self.dropboxACLs,
+    "notifications":   self.notifications,
+    "notifcationName": self.notifcationName,
+    "manhole":         self.manhole,
+    
 }
 
 if __name__ == "__main__":

Modified: CalendarServer/branches/users/cdaboo/dropbox/conf/caldavd-dev.plist
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/conf/caldavd-dev.plist	2006-10-25 19:31:21 UTC (rev 299)
+++ CalendarServer/branches/users/cdaboo/dropbox/conf/caldavd-dev.plist	2006-10-25 19:40:00 UTC (rev 300)
@@ -68,12 +68,24 @@
   <key>ResetAccountACLs</key>
   <true/>
 
+  <key>DropBoxEnabled</key>
+  <true/>
+
+  <key>DropBoxName</key>
+  <string>dropbox</string>
+
+  <key>DropBoxInheritedACLs</key>
+  <true/>
+
+  <key>NotificationsEnabled</key>
+  <true/>
+
+  <key>NotificationCollectionName</key>
+  <string>notifications</string>
+
   <key>twistdLocation</key>
   <string>../Twisted/bin/twistd</string>
 
-  <key>EventExpirationDays</key>
-  <integer>0</integer>
-
   <key>MaximumAttachmentSizeBytes</key>
   <integer>1048576</integer><!-- 1Mb -->
 

Modified: CalendarServer/branches/users/cdaboo/dropbox/conf/caldavd.plist
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/conf/caldavd.plist	2006-10-25 19:31:21 UTC (rev 299)
+++ CalendarServer/branches/users/cdaboo/dropbox/conf/caldavd.plist	2006-10-25 19:40:00 UTC (rev 300)
@@ -65,12 +65,24 @@
   <key>ResetAccountACLs</key>
   <true/>
 
+  <key>DropBoxEnabled</key>
+  <true/>
+
+  <key>DropBoxName</key>
+  <string>dropbox</string>
+
+  <key>DropBoxInheritedACLs</key>
+  <true/>
+
+  <key>NotificationsEnabled</key>
+  <true/>
+
+  <key>NotificationCollectionName</key>
+  <string>notifications</string>
+
   <key>twistdLocation</key>
   <string>/usr/share/caldavd/bin/twistd</string>
 
-  <key>EventExpirationDays</key>
-  <integer>0</integer>
-
   <key>MaximumAttachmentSizeBytes</key>
   <integer>1048576</integer><!-- 1Mb -->
 

Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py	2006-10-25 19:31:21 UTC (rev 299)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py	2006-10-25 19:40:00 UTC (rev 300)
@@ -106,6 +106,28 @@
     namespace = twisted_dav_namespace
     name = "notifications"
 
+class DropBoxHomeURL (davxml.WebDAVTextElement):
+    """
+    A principal property to indicate the location of the drop box home.
+    (Apple Extension to CalDAV)
+    """
+    name = "drop-box-home-URL"
+    hidden = True
+    protected = True
+
+    allowed_children = { (davxml.dav_namespace, "href"): (0, 1) }
+
+class NotificationsURL (davxml.WebDAVTextElement):
+    """
+    A principal property to indicate the location of the notification collection.
+    (Apple Extension to CalDAV)
+    """
+    name = "notifications-URL"
+    hidden = True
+    protected = True
+
+    allowed_children = { (davxml.dav_namespace, "href"): (0, 1) }
+
 ##
 # Extensions to davxml.ResourceType
 ##

Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/dropbox.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/dropbox.py	2006-10-25 19:31:21 UTC (rev 299)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/dropbox.py	2006-10-25 19:40:00 UTC (rev 300)
@@ -16,9 +16,11 @@
 # DRI: Cyrus Daboo, cdaboo at apple.com
 ##
 
+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
-from twistedcaldav.static import CalDAVFile
 
 """
 Implements drop-box functionality. A drop box is an external attachment store that provides
@@ -38,6 +40,39 @@
     notifcationName = "notify"    # Name of the collection in which notifications will be stored.
     
     @classmethod
+    def enable(clzz, enabled, dropboxName=None, inheritedACLs=None, notifications=None, notificationName=None):
+        """
+        This method must be used to enable drop box support as it will setup live properties etc,
+        and turn on the notification system. It must only be called once
+
+        @param enable: C{True} if drop box feature is enabled, C{False} otherwise
+        @param dropboxName: C{str} containing the name of the drop box home collection
+        @param inheritedACLs: C{True} if ACLs on drop boxes should be inherited by their contents, C{False} otehrwise.
+        @param notifications: C{True} if automatic notifications are to be sent when a drop box changes, C{False} otherwise.
+        @param notificationName: C{str} containing the name of the collection used to store per-user notifications.
+        """
+        DropBox.enabled = enabled
+        if dropboxName:
+            DropBox.dropboxName = dropboxName
+        if inheritedACLs:
+            DropBox.inheritedACLs = inheritedACLs
+        if notifications:
+            DropBox.notifications = notifications
+        if notificationName:
+            DropBox.notifcationName = notificationName
+
+        if DropBox.enabled:
+
+            # Need to setup live properties
+            assert (twisted_dav_namespace, "drop-box-home-URL") not in CalendarPrincipalResource.liveProperties, \
+                "DropBox.enable must only be called once"
+
+            CalendarPrincipalResource.liveProperties += (
+                (twisted_dav_namespace, "drop-box-home-URL"      ),
+                (twisted_dav_namespace, "notifications-URL" ),
+            )
+
+    @classmethod
     def provision(clzz, principal, cuhome):
         """
         Provision user account with appropriate collections for drop box

Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/icaldav.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/icaldav.py	2006-10-25 19:31:21 UTC (rev 299)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/icaldav.py	2006-10-25 19:40:00 UTC (rev 300)
@@ -35,6 +35,14 @@
             otherwise.
         """
 
+    def isSpecialCollection(collectiontype):
+        """
+        (CalDAV-access-10, Section 4.2)
+        @param collectiontype: L{WebDAVElement} for the collection type to test for.
+        @return: True if this resource is a collection that also has the specified type,
+            False otherwise.
+        """
+
     def isPseudoCalendarCollection():
         """
         @return: True if this resource is a calendar collection like (e.g.

Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/repository.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/repository.py	2006-10-25 19:31:21 UTC (rev 299)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/repository.py	2006-10-25 19:40:00 UTC (rev 300)
@@ -42,6 +42,7 @@
 from twisted.web2.server import Site
 
 from twistedcaldav import caldavxml, customxml
+from twistedcaldav.dropbox import DropBox
 from twistedcaldav.logging import RotatingFileAccessLoggingObserver
 from twistedcaldav.resource import CalDAVResource
 from twistedcaldav.static import CalDAVFile, CalendarHomeFile, CalendarPrincipalFile
@@ -120,7 +121,12 @@
 ELEMENT_AUTORESPOND = "autorespond"
 ATTRIBUTE_REPEAT = "repeat"
 
-def startServer(docroot, repo, doacct, doacl, dossl, keyfile, certfile, onlyssl, port, sslport, maxsize, quota, serverlogfile, manhole):
+def startServer(docroot, repo, doacct, doacl, dossl,
+                keyfile, certfile, onlyssl, port, sslport, maxsize,
+                quota, serverlogfile,
+                dropbox, dropboxName, dropboxACLs,
+                notifications, notifcationName,
+                manhole):
     """
     Start the server using XML-based configuration details and supplied .plist based options.
     """
@@ -165,6 +171,9 @@
             MultiService.stopService(self)
             self.logObserver.stop()
     
+    # Turn on drop box support before building the repository
+    DropBox.enable(dropbox, dropboxName, dropboxACLs, notifications, notifcationName)
+
     # Build the server
     builder = RepositoryBuilder(docroot,
                                 doAccounts=doacct,

Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/resource.py	2006-10-25 19:31:21 UTC (rev 299)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/resource.py	2006-10-25 19:40:00 UTC (rev 300)
@@ -33,8 +33,6 @@
     "isScheduleOutboxResource",
 ]
 
-from weakref import WeakValueDictionary
-
 from zope.interface import implements
 
 from twisted.internet import reactor
@@ -47,6 +45,7 @@
 from twisted.web2.dav.http import ErrorResponse
 from twisted.web2.dav.resource import DAVResource, TwistedACLInheritable
 from twisted.web2.dav.util import joinURL, parentForURL, unimplemented
+from twisted.web2.dav.element.base import twisted_dav_namespace
 from twisted.web2.http import HTTPError, RedirectResponse, StatusResponse, Response
 from twisted.web2.http_headers import MimeType
 from twisted.web2.iweb import IResponse
@@ -54,7 +53,7 @@
 import twisted.web2.server
 
 import twistedcaldav
-from twistedcaldav import caldavxml
+from twistedcaldav import caldavxml, customxml
 from twistedcaldav.icaldav import ICalDAVResource, ICalendarPrincipalResource, ICalendarSchedulingCollectionResource
 from twistedcaldav.caldavxml import caldav_namespace
 from twistedcaldav.ical import Component as iComponent
@@ -234,11 +233,17 @@
         """
         See L{ICalDAVResource.isCalendarCollection}.
         """
+        return self.isSpecialCollection(caldavxml.Calendar)
+
+    def isSpecialCollection(self, collectiontype):
+        """
+        See L{ICalDAVResource.isSpecialCollection}.
+        """
         if not self.isCollection(): return False
 
         try:
             resourcetype = self.readDeadProperty((dav_namespace, "resourcetype"))
-            return resourcetype.isCalendar()
+            return bool(resourcetype.childrenOfType(collectiontype))
         except HTTPError, e:
             assert e.response.code == responsecode.NOT_FOUND
             return False
@@ -583,6 +588,23 @@
                     else:
                         return caldavxml.ScheduleOutboxURL(davxml.HRef(url))
 
+            elif namespace == twisted_dav_namespace:
+                from twistedcaldav.dropbox import DropBox
+                if name == "drop-box-home-URL":
+                    # Use the first calendar home only
+                    home = ""
+                    for url in self.calendarHomeURLs():
+                        home = joinURL(url, DropBox.dropboxName) + "/"
+                    return customxml.DropBoxHomeURL(davxml.HRef(home))
+
+                if name == "notifications-URL":
+                    # Use the first calendar home only
+                    home = ""
+                    for url in self.calendarHomeURLs():
+                        home = joinURL(url, DropBox.notifcationName) + "/"
+                    return customxml.NotificationsURL(davxml.HRef(home))
+
+
             return super(CalendarPrincipalResource, self).readProperty(property, request)
 
         return maybeDeferred(defer)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061025/c9bfda61/attachment.html


More information about the calendarserver-changes mailing list