Revision
2084
Author
cdaboo@apple.com
Date
2008-01-02 09:21:03 -0800 (Wed, 02 Jan 2008)

Log Message

Config option to enable private events, and DAV compliance class (with some refactoring to allow adding new
compliance classes to be easier in the future).

Modified Paths

Diff

Modified: CalendarServer/branches/users/cdaboo/private_events-2081/conf/caldavd-test.plist (2083 => 2084)


--- CalendarServer/branches/users/cdaboo/private_events-2081/conf/caldavd-test.plist	2008-01-02 16:42:55 UTC (rev 2083)
+++ CalendarServer/branches/users/cdaboo/private_events-2081/conf/caldavd-test.plist	2008-01-02 17:21:03 UTC (rev 2084)
@@ -330,7 +330,11 @@
   <key>EnableNotifications</key>
   <true/>
 
+  <!-- Private Events -->
+  <key>EnablePrivateEvents</key>
+  <true/>
 
+
   <!--
     Twisted
   -->

Modified: CalendarServer/branches/users/cdaboo/private_events-2081/conf/caldavd.plist (2083 => 2084)


--- CalendarServer/branches/users/cdaboo/private_events-2081/conf/caldavd.plist	2008-01-02 16:42:55 UTC (rev 2083)
+++ CalendarServer/branches/users/cdaboo/private_events-2081/conf/caldavd.plist	2008-01-02 17:21:03 UTC (rev 2084)
@@ -264,6 +264,10 @@
   <key>EnableNotifications</key>
   <true/>
 
+  <!-- Private Events -->
+  <key>EnablePrivateEvents</key>
+  <true/>
 
+
 </dict>
 </plist>

Modified: CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/config.py (2083 => 2084)


--- CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/config.py	2008-01-02 16:42:55 UTC (rev 2083)
+++ CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/config.py	2008-01-02 17:21:03 UTC (rev 2084)
@@ -145,6 +145,7 @@
     #
     "EnableDropBox"      : False, # Calendar Drop Box
     "EnableNotifications": False, # Drop Box Notifications
+    "EnablePrivateEvents": False, # Private Events
 
     #
     # Implementation details

Modified: CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/customxml.py (2083 => 2084)


--- CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/customxml.py	2008-01-02 16:42:55 UTC (rev 2083)
+++ CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/customxml.py	2008-01-02 17:21:03 UTC (rev 2084)
@@ -34,6 +34,10 @@
     "calendar-proxy",
 )
 
+calendarserver_private_events_compliance = (
+    "calendarserver-private-events",
+)
+
 class TwistedGUIDProperty (davxml.WebDAVTextElement):
     """
     Contains the GUID value for a directory record corresponding to a principal.

Modified: CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/directory/calendaruserproxy.py (2083 => 2084)


--- CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/directory/calendaruserproxy.py	2008-01-02 16:42:55 UTC (rev 2083)
+++ CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/directory/calendaruserproxy.py	2008-01-02 17:21:03 UTC (rev 2084)
@@ -33,11 +33,10 @@
 from twisted.web2.dav.util import joinURL
 from twisted.web2.http import HTTPError, StatusResponse
 
-from twistedcaldav import caldavxml
-from twistedcaldav import customxml
 from twistedcaldav.config import config
 from twistedcaldav.extensions import DAVFile, DAVPrincipalResource
 from twistedcaldav.extensions import ReadOnlyWritePropertiesResourceMixIn
+from twistedcaldav.resource import CalDAVComplianceMixIn
 from twistedcaldav.sql import AbstractSQLDatabase
 from twistedcaldav.sql import db_prefix
 from twistedcaldav.static import AutoProvisioningFileMixIn
@@ -74,16 +73,13 @@
         # Permissions here are fixed, and are not subject to inherritance rules, etc.
         return succeed(self.defaultAccessControlList())
 
-class CalendarUserProxyPrincipalResource (AutoProvisioningFileMixIn, PermissionsMixIn, DAVPrincipalResource, DAVFile):
+class CalendarUserProxyPrincipalResource (AutoProvisioningFileMixIn, PermissionsMixIn, DAVPrincipalResource, DAVFile, CalDAVComplianceMixIn):
     """
     Calendar user proxy principal resource.
     """
 
     def davComplianceClasses(self):
-        extra_compliance = caldavxml.caldav_compliance
-        if config.EnableProxyPrincipals:
-            extra_compliance += customxml.calendarserver_proxy_compliance
-        return tuple(super(CalendarUserProxyPrincipalResource, self).davComplianceClasses()) + extra_compliance
+        return tuple(super(CalendarUserProxyPrincipalResource, self).davComplianceClasses()) + self.caldavComplianceClasses()
 
     def __init__(self, path, parent, proxyType):
         """

Modified: CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/resource.py (2083 => 2084)


--- CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/resource.py	2008-01-02 16:42:55 UTC (rev 2083)
+++ CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/resource.py	2008-01-02 17:21:03 UTC (rev 2084)
@@ -19,6 +19,7 @@
 """
 
 __all__ = [
+    "CalDAVComplianceMixIn",
     "CalDAVResource",
     "CalendarPrincipalCollectionResource",
     "CalendarPrincipalResource",
@@ -59,7 +60,18 @@
 else:
     serverVersion = twisted.web2.server.VERSION + " TwistedCalDAV/?"
 
-class CalDAVResource (DAVResource):
+class CalDAVComplianceMixIn(object):
+
+    def caldavComplianceClasses(self):
+        extra_compliance = caldavxml.caldav_compliance
+        if config.EnableProxyPrincipals:
+            extra_compliance += customxml.calendarserver_proxy_compliance
+        if config.EnablePrivateEvents:
+            extra_compliance += customxml.calendarserver_private_events_compliance
+        return extra_compliance
+
+
+class CalDAVResource (DAVResource, CalDAVComplianceMixIn):
     """
     CalDAV resource.
 
@@ -118,10 +130,7 @@
     ##
 
     def davComplianceClasses(self):
-        extra_compliance = caldavxml.caldav_compliance
-        if config.EnableProxyPrincipals:
-            extra_compliance += customxml.calendarserver_proxy_compliance
-        return tuple(super(CalDAVResource, self).davComplianceClasses()) + extra_compliance
+        return tuple(super(CalDAVResource, self).davComplianceClasses()) + self.caldavComplianceClasses()
 
     liveProperties = DAVResource.liveProperties + (
         (caldav_namespace, "supported-calendar-component-set"),
@@ -471,7 +480,7 @@
             ),
         )
 
-class CalendarPrincipalResource (DAVPrincipalResource):
+class CalendarPrincipalResource (DAVPrincipalResource, CalDAVComplianceMixIn):
     """
     CalDAV principal resource.
 
@@ -480,10 +489,7 @@
     implements(ICalendarPrincipalResource)
 
     def davComplianceClasses(self):
-        extra_compliance = caldavxml.caldav_compliance
-        if config.EnableProxyPrincipals:
-            extra_compliance += customxml.calendarserver_proxy_compliance
-        return tuple(super(CalendarPrincipalResource, self).davComplianceClasses()) + extra_compliance
+        return tuple(super(CalendarPrincipalResource, self).davComplianceClasses()) + self.caldavComplianceClasses()
 
     liveProperties = tuple(DAVPrincipalResource.liveProperties) + (
         (caldav_namespace, "calendar-home-set"        ),

Modified: CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/test/test_config.py (2083 => 2084)


--- CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/test/test_config.py	2008-01-02 16:42:55 UTC (rev 2083)
+++ CalendarServer/branches/users/cdaboo/private_events-2081/twistedcaldav/test/test_config.py	2008-01-02 17:21:03 UTC (rev 2084)
@@ -25,16 +25,15 @@
 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-  <key>Verbose</key>
-  <true/>
-  <key>HTTPPort</key>
-  <integer>8008</integer>
+    <key>Verbose</key>
+    <true/>
+    <key>HTTPPort</key>
+    <integer>8008</integer>
 </dict>
 </plist>
 """
 
 def _testVerbose(testCase):
-    from twistedcaldav.config import config
     testCase.assertEquals(config.Verbose, True)
 
 
@@ -222,3 +221,9 @@
         
         config.EnableProxyPrincipals = False
         self.assertTrue("calendar-proxy" not in resource.davComplianceClasses())
+        
+        config.EnablePrivateEvents = True
+        self.assertTrue("calendarserver-private-events" in resource.davComplianceClasses())
+        
+        config.EnablePrivateEvents = False
+        self.assertTrue("calendarserver-private-events" not in resource.davComplianceClasses())