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

source_changes at macosforge.org source_changes at macosforge.org
Tue Oct 3 11:56:30 PDT 2006


Revision: 233
          http://trac.macosforge.org/projects/calendarserver/changeset/233
Author:   cdaboo at apple.com
Date:     2006-10-03 11:56:29 -0700 (Tue, 03 Oct 2006)

Log Message:
-----------
Optimize directory access to not scan the directory server everytime the calendar server needs to iterate over known principals.

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

Modified: CalendarServer/trunk/twistedcaldav/directory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory.py	2006-10-03 15:38:26 UTC (rev 232)
+++ CalendarServer/trunk/twistedcaldav/directory.py	2006-10-03 18:56:29 UTC (rev 233)
@@ -694,7 +694,7 @@
             return []
         
         result = []
-        for name in self.listFileChildren():
+        for name in self.listChildren():
             principal = self.getChild(name)
             if principal.hasDeadProperty(customxml.TwistedGroupMemberGUIDs):
                 guids = principal.readDeadProperty(customxml.TwistedGroupMemberGUIDs)
@@ -711,48 +711,23 @@
         """
         return True
 
-    def listChildren(self):
+    def getChild(self, name):
         """
-        @return: a sequence of the names of all known children of this resource.
+        Look up a child resource.
+        @return: the child of this resource with the given name.
         """
-        
-        # Lookup all users
-        return self.listNames()
- 
-    def listFileChildren(self):
-        """
-        @return: a sequence of the names of all known file children of this resource.
-        """
-        
-        # Lookup all users
-        return DAVFile.listChildren(self)
- 
-    def getChild(self, name):
-        if name == "": return self
+        if name == "":
+            return self
 
+        child = self.putChildren.get(name, None)
+        if child: return child
+
         child_fp = self.fp.child(name)
         if child_fp.exists():
-            assert child_fp.isfile()
+            return DirectoryPrincipalFile(self, child_fp.path, joinURL(self._url, name))
         else:
-            assert self.exists()
-            assert self.isCollection()
+            return None
 
-            # FIXME: Do a real lookup of what's valid here
-            if name[0] == ".": return None
-            
-            # Verify that name is valid in the directory
-            if not self.validName(name):
-                return None
-
-            # Verify that this directory entry is one that supports clendars
-            dattrs = self.directoryAttributes(name)
-            if not dattrs.has_key(dsattributes.attrCalendarPrincipalURI):
-                return None
-
-            self.addPrincipal(name)
-
-        return DirectoryPrincipalFile(self, child_fp.path, joinURL(self._url, name))
-
     def principalSearchPropertySet(self):
         """
         See L{IDAVResource.principalSearchPropertySet}.        

Modified: CalendarServer/trunk/twistedcaldav/principalindex.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/principalindex.py	2006-10-03 15:38:26 UTC (rev 232)
+++ CalendarServer/trunk/twistedcaldav/principalindex.py	2006-10-03 18:56:29 UTC (rev 233)
@@ -64,7 +64,7 @@
 
         # Now verify that index entries have a corresponding child
         indexnames = set(self.listNames())
-        filenames = set(self.resource.listFileChildren())
+        filenames = set(self.resource.listChildren())
         extranames = indexnames.difference(filenames)
         for name in extranames:
             self.deleteName(name)
@@ -231,7 +231,7 @@
         This allows for index recovery if the DB file gets deleted.
         """
 
-        for name in self.resource.listFileChildren():
+        for name in self.resource.listChildren():
             if name == db_basename: continue
             principal = self.resource.getChild(name)
             #if not isinstance(principal, DirectoryPrincipalFile): continue

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


More information about the calendarserver-changes mailing list