[CalendarServer-changes] [178] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Thu Sep 21 19:49:47 PDT 2006


Revision: 178
          http://trac.macosforge.org/projects/collaboration/changeset/178
Author:   wsanchez at apple.com
Date:     2006-09-21 19:49:46 -0700 (Thu, 21 Sep 2006)

Log Message:
-----------
Twisted r18219.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory.py
    CalendarServer/trunk/twistedcaldav/static.py

Modified: CalendarServer/trunk/twistedcaldav/directory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory.py	2006-09-22 02:49:25 UTC (rev 177)
+++ CalendarServer/trunk/twistedcaldav/directory.py	2006-09-22 02:49:46 UTC (rev 178)
@@ -39,7 +39,6 @@
 from twisted.web2 import responsecode
 from twisted.web2.dav import davxml
 from twisted.web2.dav.auth import IPrincipalCredentials
-from twisted.web2.dav.resource import TwistedAccessDisabledProperty
 from twisted.web2.dav.static import DAVFile
 from twisted.web2.dav.util import joinURL
 from twisted.web2.http import HTTPError
@@ -250,21 +249,20 @@
         @param calhome: L{DAVFile} for the container of the calendar home of this user.
         @param enable: C{True} to enable, C{False} to disable.
         """
-        
         # Get home collection resource
         calrsrc = calhome.getChild(self.principalUID())
 
         # Handle access for the calendar home
         if enable:
-            calrsrc.removeDeadProperty(TwistedAccessDisabledProperty)
+            calrsrc.disable(False)
         else:
-            calrsrc.writeDeadProperty(TwistedAccessDisabledProperty())
+            calrsrc.disable(True)
 
     def remove(self, calhome):
         """
         Remove this principal by hiding (archiving) any calendars owned by it. This is done
-        by turning on the TwistedAccessDisabledProperty and renaming the calendar home to ensure
-        a future user with the same id won't see the old calendars.
+        by turning on the disabling and renaming the calendar home to ensure a future user
+        with the same id won't see the old calendars.
         
         @param calhome: L{DAVFile} for the container of the calendar home of this user.
         """
@@ -273,7 +271,7 @@
         calrsrc = calhome.getChild(self.principalUID())
 
         # Disable access for the calendar home
-        calrsrc.writeDeadProperty(TwistedAccessDisabledProperty())
+        calrsrc.disable(True)
         
         # Rename the calendar home to the original name with the GUID appended
         newname = self.principalUID() + "-" + self.getPropertyValue(customxml.TwistedGUIDProperty)
@@ -292,8 +290,7 @@
                     (calrsrc.fp.path, calrsrc.fp.sibling(newname).path))
             
             # Remove the disabled property to prevent lock out in the future
-            calrsrc.removeDeadProperty(TwistedAccessDisabledProperty())
-           
+            calrsrc.disable(False)
 
 class DirectoryTypePrincipalProvisioningResource (CalendarPrincipalCollectionResource, DAVFile):
     """

Modified: CalendarServer/trunk/twistedcaldav/static.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/static.py	2006-09-22 02:49:25 UTC (rev 177)
+++ CalendarServer/trunk/twistedcaldav/static.py	2006-09-22 02:49:46 UTC (rev 178)
@@ -551,6 +551,31 @@
             if not child_fp.exists(): child_fp.makedirs()
             self.putChild(name, clazz(child_fp.path))
 
+    def disable(self, disabled=True):
+        """
+        Completely disables all access to this resource, regardless of ACL
+        settings.
+        @param disabled: If true, disabled all access. If false, enables access.
+        """
+        if disabled:
+            self.writeDeadProperty(AccessDisabled)
+        else:
+            self.removeDeadProperty(AccessDisabled)
+
+    def isDisabled(self):
+        """
+        @return: C{True} if access to this resource is disabled, C{False}
+            otherwise.
+        """
+        return self.hasDeadProperty(AccessDisabled)
+
+    # FIXME: Perhaps this is better done in authorize() instead.
+    def accessControlList(self, *args, **kwargs):
+        if self.isDisabled():
+            return succeed(None)
+
+        super(CalDAVResource, self).accessControlList(*args, **kwargs)
+
     def createSimilarFile(self, path):
         return CalDAVFile(path)
 
@@ -902,6 +927,16 @@
         )
 
 ##
+# Utilities
+##
+
+class AccessDisabled (davxml.WebDAVEmptyElement):
+    namespace = davxml.twisted_private_namespace
+    name = "caldav-access-disabled"
+
+davxml.registerElement(AccessDisabled)
+
+##
 # Attach methods
 ##
 

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


More information about the calendarserver-changes mailing list