[CalendarServer-changes] [5981] CalendarServer/trunk/twistedcaldav/resource.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Aug 5 09:11:16 PDT 2010


Revision: 5981
          http://trac.macosforge.org/projects/calendarserver/changeset/5981
Author:   cdaboo at apple.com
Date:     2010-08-05 09:11:14 -0700 (Thu, 05 Aug 2010)
Log Message:
-----------
Faster method for finding collections.

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

Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py	2010-08-05 02:38:06 UTC (rev 5980)
+++ CalendarServer/trunk/twistedcaldav/resource.py	2010-08-05 16:11:14 UTC (rev 5981)
@@ -919,6 +919,26 @@
 
         return completionDeferred
 
+    @inlineCallbacks
+    def findSpecialCollectionsFaster(self, type, depth, request, callback, privileges=None):
+        assert depth in ("0", "1", "infinity"), "Invalid depth: %s" % (depth,)
+
+        if depth != "0" and self.isCollection():
+            basepath = request.urlForResource(self)
+            for childname in self.listChildren():
+                childpath = joinURL(basepath, childname)
+                child = (yield request.locateResource(childpath))
+                if privileges:
+                    try:
+                        child.checkPrivileges(request, privileges)
+                    except AccessDeniedError:
+                        continue
+                if child.isSpecialCollection(type):
+                    callback(child, childpath)
+                elif child.isCollection():
+                    if depth == "infinity":
+                        yield child.findSpecialCollectionsFaster(type, depth, request, callback, privileges)                
+
     def createCalendar(self, request):
         """
         See L{ICalDAVResource.createCalendar}.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100805/13b448f1/attachment.html>


More information about the calendarserver-changes mailing list