[CalendarServer-changes] [249] CalendarServer/trunk/twistedcaldav/static.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 4 18:28:33 PDT 2006


Revision: 249
          http://trac.macosforge.org/projects/calendarserver/changeset/249
Author:   wsanchez at apple.com
Date:     2006-10-04 18:28:33 -0700 (Wed, 04 Oct 2006)

Log Message:
-----------
Also be persnikety about case variants in CalendarHomeProvisioningFile.

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

Modified: CalendarServer/trunk/twistedcaldav/static.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/static.py	2006-10-05 01:01:13 UTC (rev 248)
+++ CalendarServer/trunk/twistedcaldav/static.py	2006-10-05 01:28:33 UTC (rev 249)
@@ -599,19 +599,9 @@
             if not child_fp.exists(): child_fp.makedirs()
             self.putChild(name, clazz(child_fp.path))
 
-    def locateChild(self, req, segments):
-        """
-        This implementation tries fails to find children we don't already know
-        about.
-        """
-        # If getChild() finds a child resource, return it
-        child = self.getChild(segments[0])
-        if child is not None:
-            return (child, segments[1:])
+    def locateChild(self, request, segments):
+        return locateExistingChild(self, request, segments)
 
-        # Otherwise, there is no child
-        return (None, ())
-
     def getChild(self, name):
         # This avoids finding case variants of put children on case-insensitive filesystems.
         if name not in self.putChildren and name.lower() in (x.lower() for x in self.putChildren):
@@ -661,9 +651,16 @@
         """
         return name in self.listChildren()
 
+    def locateChild(self, request, segments):
+        return locateExistingChild(self, request, segments)
+
     def getChild(self, name):
         if name == "": return self
 
+        # Avoid case variants when allocating resources
+        if not self.hasChild(name):
+            return None
+
         child_fp = self.fp.child(name)
         if child_fp.exists():
             assert child_fp.isdir()
@@ -671,9 +668,6 @@
             assert self.exists()
             assert self.isCollection()
 
-            if not self.hasChild(name):
-                return None
-
             child_fp.makedirs()
 
         return self.calendarHomeClass(child_fp.path)
@@ -946,6 +940,23 @@
     def http_MKCALENDAR (self, request): return responsecode.FORBIDDEN
 
 ##
+# Utilities
+##
+
+def locateExistingChild(resource, request, segments):
+    """
+    This C{locateChild()} implementation fails to find children if C{getChild()}
+    doesn't return one.
+    """
+    # If getChild() finds a child resource, return it
+    child = resource.getChild(segments[0])
+    if child is not None:
+        return (child, segments[1:])
+
+    # Otherwise, there is no child
+    return (None, ())
+
+##
 # Attach methods
 ##
 

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


More information about the calendarserver-changes mailing list