[CalendarServer-changes] [4571] CalendarServer/branches/users/wsanchez/deployment

source_changes at macosforge.org source_changes at macosforge.org
Fri Oct 2 18:41:39 PDT 2009


Revision: 4571
          http://trac.macosforge.org/projects/calendarserver/changeset/4571
Author:   cdaboo at apple.com
Date:     2009-10-02 18:41:35 -0700 (Fri, 02 Oct 2009)
Log Message:
-----------
Remove stat per child for PROPFIND Depth:1 on a calendar.

Modified Paths:
--------------
    CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.python.filepath.patch
    CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.static.patch
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/test_proxyprincipalmembers.py
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/static.py

Modified: CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.python.filepath.patch
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.python.filepath.patch	2009-10-03 01:08:48 UTC (rev 4570)
+++ CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.python.filepath.patch	2009-10-03 01:41:35 UTC (rev 4571)
@@ -2,17 +2,75 @@
 ===================================================================
 --- twisted/python/filepath.py	(revision 19773)
 +++ twisted/python/filepath.py	(working copy)
-@@ -370,6 +370,9 @@
+@@ -286,9 +286,11 @@
+     statinfo = None
+     path = None
  
+-    def __init__(self, path, alwaysCreate=False):
++    def __init__(self, path, alwaysCreate=False, existsCached=None, isDirCached=None):
+         self.path = abspath(path)
+         self.alwaysCreate = alwaysCreate
++        self.existsCached = existsCached
++        self.isDirCached = isDirCached
+ 
+     def __getstate__(self):
+         d = self.__dict__.copy()
+@@ -370,6 +372,11 @@
+ 
      # stat methods below
  
 +    def changed(self):
 +        self.statinfo = None
++        self.existsCached = None
++        self.isDirCached = None
 +
      def restat(self, reraise=True):
          """
          Re-calculate cached effects of 'stat'.  To refresh information on this path
-@@ -496,7 +499,7 @@
+@@ -381,11 +388,22 @@
+         """
+         try:
+             self.statinfo = stat(self.path)
++            self.existsCached = True
++            self.isDirCached = S_ISDIR(self.statinfo.st_mode)
+         except OSError:
+             self.statinfo = 0
++            self.existsCached = False
++            self.isDirCached = None
+             if reraise:
+                 raise
+ 
++    def getstatinfo(self):
++        st = self.statinfo
++        if not st:
++            self.restat()
++            st = self.statinfo
++        return st
++
+     def getsize(self):
+         st = self.statinfo
+         if not st:
+@@ -437,7 +455,9 @@
+ 
+ 
+     def exists(self):
+-        if self.statinfo:
++        if self.existsCached is not None:
++            return self.existsCached
++        elif self.statinfo:
+             return True
+         elif self.statinfo is None:
+             self.restat(False)
+@@ -446,6 +466,8 @@
+             return False
+ 
+     def isdir(self):
++        if self.isDirCached is not None:
++            return self.isDirCached
+         st = self.statinfo
+         if not st:
+             self.restat(False)
+@@ -496,7 +518,7 @@
              os.rmdir(self.path)
          else:
              os.remove(self.path)
@@ -21,7 +79,7 @@
  
      def makedirs(self):
          return os.makedirs(self.path)
-@@ -600,7 +603,7 @@
+@@ -600,7 +622,7 @@
      def moveTo(self, destination):
          try:
              os.rename(self.path, destination.path)

Modified: CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.static.patch
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.static.patch	2009-10-03 01:08:48 UTC (rev 4570)
+++ CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.static.patch	2009-10-03 01:41:35 UTC (rev 4571)
@@ -14,7 +14,7 @@
          # Remove the dots from the path to split
          self.defaultType = defaultType
          self.ignoredExts = list(ignoredExts)
-@@ -213,6 +216,13 @@
+@@ -213,13 +216,20 @@
          if indexNames is not None:
              self.indexNames = indexNames
  
@@ -28,16 +28,36 @@
      def exists(self):
          return self.fp.exists()
  
-@@ -318,7 +328,7 @@
+     def etag(self):
+         if not self.fp.exists(): return None
  
+-        st = self.fp.statinfo
++        st = self.fp.getstatinfo()
+ 
+         #
+         # Mark ETag as weak if it was modified more recently than we can
+@@ -317,8 +327,11 @@
+         if child: return child
+ 
          child_fp = self.fp.child(name)
++        if hasattr(self, "knownChildren"):
++            if name in self.knownChildren:
++                child_fp.existsCached = True
          if child_fp.exists():
 -            return self.createSimilarFile(child_fp.path)
 +            return self.createSimilarFile(child_fp)
          else:
              return None
  
-@@ -374,7 +384,7 @@
+@@ -329,6 +342,7 @@
+         children = self.putChildren.keys()
+         if self.fp.isdir():
+             children += [c for c in self.fp.listdir() if c not in children]
++            self.knownChildren = set(children)
+         return children
+ 
+     def locateChild(self, req, segments):
+@@ -374,7 +388,7 @@
          return self.createSimilarFile(fpath.path), segments[1:]
  
      def renderHTTP(self, req):
@@ -46,7 +66,7 @@
          return super(File, self).renderHTTP(req)
  
      def render(self, req):
-@@ -383,7 +393,7 @@
+@@ -383,7 +397,7 @@
              return responsecode.NOT_FOUND
  
          if self.fp.isdir():

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/test_proxyprincipalmembers.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/test_proxyprincipalmembers.py	2009-10-03 01:08:48 UTC (rev 4570)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/test_proxyprincipalmembers.py	2009-10-03 01:41:35 UTC (rev 4571)
@@ -14,7 +14,7 @@
 # limitations under the License.
 ##
 
-from twisted.internet.defer import DeferredList, inlineCallbacks
+from twisted.internet.defer import DeferredList, inlineCallbacks, succeed
 from twisted.web2.dav import davxml
 
 from twistedcaldav.directory.directory import DirectoryService
@@ -201,6 +201,7 @@
         d.addCallback(check)
         return d
 
+    @inlineCallbacks
     def test_setGroupMemberSet(self):
         class StubMemberDB(object):
             def __init__(self):
@@ -208,9 +209,10 @@
 
             def setGroupMembers(self, uid, members):
                 self.members = members
+                return succeed(None)
 
             def getMembers(self, uid):
-                return self.members
+                return succeed(self.members)
 
 
         user = self._getPrincipalByShortName(directoryService.recordType_users,
@@ -228,14 +230,14 @@
             davxml.HRef.fromString(
                 "/XMLDirectoryService/__uids__/5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1/"))
 
-        proxyGroup.setGroupMemberSet(new_members, None)
+        yield proxyGroup.setGroupMemberSet(new_members, None)
 
         self.assertEquals(
             set([str(p) for p in memberdb.members]),
             set(["5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1",
                  "8B4288F6-CC82-491D-8EF9-642EF4F3E7D0"]))
 
-
+    @inlineCallbacks
     def test_setGroupMemberSetNotifiesPrincipalCaches(self):
         class StubCacheNotifier(object):
             changedCount = 0
@@ -255,7 +257,7 @@
 
             self.assertEquals(notifier.changedCount, 0)
 
-            proxyGroup.setGroupMemberSet(
+            yield proxyGroup.setGroupMemberSet(
                 davxml.GroupMemberSet(
                     davxml.HRef.fromString(
                         "/XMLDirectoryService/__uids__/5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1/")),

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/static.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/static.py	2009-10-03 01:08:48 UTC (rev 4570)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/static.py	2009-10-03 01:41:35 UTC (rev 4571)
@@ -40,6 +40,7 @@
 
 from twisted.internet.defer import fail, succeed, inlineCallbacks, returnValue
 from twisted.python.failure import Failure
+from twisted.python.filepath import FilePath
 from twisted.web2 import responsecode
 from twisted.web2.http import HTTPError, StatusResponse
 from twisted.web2.dav import davxml
@@ -339,6 +340,13 @@
         similar = super(CalDAVFile, self).createSimilarFile(path)
 
         if isCalendarCollectionResource(self):
+
+			# Short-circuit stat with information we know to be true at this point
+            if isinstance(path, FilePath) and hasattr(self, "knownChildren"):
+                if os.path.basename(path.path) in self.knownChildren:
+                    path.existsCached = True
+                    path.isDirCached = False
+
             #
             # Override the dead property store
             #
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20091002/7ed148e6/attachment.html>


More information about the calendarserver-changes mailing list