[CalendarServer-changes] [4462] CalendarServer/branches/more-deferreds
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jul 15 17:37:50 PDT 2009
Revision: 4462
http://trac.macosforge.org/projects/calendarserver/changeset/4462
Author: william_short at apple.com
Date: 2009-07-15 17:37:50 -0700 (Wed, 15 Jul 2009)
Log Message:
-----------
Address review comments. Defer "listChildren" as well.
Modified Paths:
--------------
CalendarServer/branches/more-deferreds/calendarserver/platform/darwin/_sacl.c
CalendarServer/branches/more-deferreds/calendarserver/provision/root.py
CalendarServer/branches/more-deferreds/calendarserver/provision/test/test_root.py
CalendarServer/branches/more-deferreds/calendarserver/tap/caldav.py
CalendarServer/branches/more-deferreds/calendarserver/tap/test/test_caldav.py
CalendarServer/branches/more-deferreds/calendarserver/tools/export.py
CalendarServer/branches/more-deferreds/calendarserver/tools/principals.py
CalendarServer/branches/more-deferreds/calendarserver/tools/util.py
CalendarServer/branches/more-deferreds/calendarserver/tools/warmup.py
CalendarServer/branches/more-deferreds/calendarserver/webcal/resource.py
CalendarServer/branches/more-deferreds/conf/auth/accounts-test.xml
CalendarServer/branches/more-deferreds/conf/caldavd-apple.plist
CalendarServer/branches/more-deferreds/conf/caldavd-test.plist
CalendarServer/branches/more-deferreds/conf/caldavd.plist
CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.application.app.patch
CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.mail.imap4.patch
CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.python.util.patch
CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.auth.digest.patch
CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.method.report.patch
CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.resource.patch
CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.error.patch
CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.server.patch
CalendarServer/branches/more-deferreds/run
CalendarServer/branches/more-deferreds/setup.py
CalendarServer/branches/more-deferreds/support/Makefile.Apple
CalendarServer/branches/more-deferreds/test
CalendarServer/branches/more-deferreds/testcaldav
CalendarServer/branches/more-deferreds/twext/internet/ssl.py
CalendarServer/branches/more-deferreds/twisted/plugins/caldav.py
CalendarServer/branches/more-deferreds/twistedcaldav/accesslog.py
CalendarServer/branches/more-deferreds/twistedcaldav/caldavxml.py
CalendarServer/branches/more-deferreds/twistedcaldav/config.py
CalendarServer/branches/more-deferreds/twistedcaldav/directory/cachingdirectory.py
CalendarServer/branches/more-deferreds/twistedcaldav/directory/calendar.py
CalendarServer/branches/more-deferreds/twistedcaldav/directory/directory.py
CalendarServer/branches/more-deferreds/twistedcaldav/directory/principal.py
CalendarServer/branches/more-deferreds/twistedcaldav/directory/resource.py
CalendarServer/branches/more-deferreds/twistedcaldav/directory/test/test_principal.py
CalendarServer/branches/more-deferreds/twistedcaldav/directory/util.py
CalendarServer/branches/more-deferreds/twistedcaldav/extensions.py
CalendarServer/branches/more-deferreds/twistedcaldav/freebusyurl.py
CalendarServer/branches/more-deferreds/twistedcaldav/ical.py
CalendarServer/branches/more-deferreds/twistedcaldav/icaldav.py
CalendarServer/branches/more-deferreds/twistedcaldav/index.py
CalendarServer/branches/more-deferreds/twistedcaldav/mail.py
CalendarServer/branches/more-deferreds/twistedcaldav/memcacheprops.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/delete.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/delete_common.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/get.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/mkcalendar.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/mkcol.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/propfind.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/put.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/put_common.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/report.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/report_calquery.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/report_common.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/report_freebusy.py
CalendarServer/branches/more-deferreds/twistedcaldav/method/report_multiget.py
CalendarServer/branches/more-deferreds/twistedcaldav/notify.py
CalendarServer/branches/more-deferreds/twistedcaldav/resource.py
CalendarServer/branches/more-deferreds/twistedcaldav/schedule.py
CalendarServer/branches/more-deferreds/twistedcaldav/scheduling/addressmapping.py
CalendarServer/branches/more-deferreds/twistedcaldav/scheduling/caldav.py
CalendarServer/branches/more-deferreds/twistedcaldav/scheduling/implicit.py
CalendarServer/branches/more-deferreds/twistedcaldav/scheduling/ischedule.py
CalendarServer/branches/more-deferreds/twistedcaldav/scheduling/itip.py
CalendarServer/branches/more-deferreds/twistedcaldav/scheduling/processing.py
CalendarServer/branches/more-deferreds/twistedcaldav/scheduling/scheduler.py
CalendarServer/branches/more-deferreds/twistedcaldav/scheduling/utils.py
CalendarServer/branches/more-deferreds/twistedcaldav/static.py
CalendarServer/branches/more-deferreds/twistedcaldav/test/test_collectioncontents.py
CalendarServer/branches/more-deferreds/twistedcaldav/test/test_config.py
CalendarServer/branches/more-deferreds/twistedcaldav/test/test_memcacheprops.py
CalendarServer/branches/more-deferreds/twistedcaldav/test/test_notify.py
CalendarServer/branches/more-deferreds/twistedcaldav/test/test_sql.py
CalendarServer/branches/more-deferreds/twistedcaldav/test/test_static.py
CalendarServer/branches/more-deferreds/twistedcaldav/test/test_timezones.py
CalendarServer/branches/more-deferreds/twistedcaldav/test/util.py
Added Paths:
-----------
CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.static.patch
CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.test.test_resource.patch
CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch
CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.static.patch
Property Changed:
----------------
CalendarServer/branches/more-deferreds/
Property changes on: CalendarServer/branches/more-deferreds
___________________________________________________________________
Modified: svn:mergeinfo
- /CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
+ /CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/config-separation:4379-4443
Modified: CalendarServer/branches/more-deferreds/calendarserver/tools/export.py
===================================================================
--- CalendarServer/branches/more-deferreds/calendarserver/tools/export.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/calendarserver/tools/export.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -37,6 +37,8 @@
from os.path import dirname, abspath
from twistedcaldav.config import ConfigurationError
+from twisted.internet.defer import gatherResults
+
from twistedcaldav.ical import Component as iComponent, Property as iProperty
from twistedcaldav.ical import iCalendarProductID
from twistedcaldav.resource import isCalendarCollectionResource
@@ -153,6 +155,12 @@
sys.stdout.write("%s\n" % (e,))
sys.exit(1)
+ def _gotChildren(children):
+ for childName in children:
+ child = calendarHome.getChild(childName)
+ if isCalendarCollectionResource(child):
+ collections.add(child)
+
for record in records:
recordType, shortName = record
calendarHome = config.directory.calendarHomeForShortName(recordType, shortName)
@@ -161,63 +169,60 @@
sys.exit(1)
calendarHomes.add(calendarHome)
- for calendarHome in calendarHomes:
- for childName in calendarHome.listChildren():
- child = calendarHome.getChild(childName)
- if isCalendarCollectionResource(child):
- collections.add(child)
+ d = gatherResults([calendarHome.listChildren().addCallback(_gotChildren) for calendarHome in calendarHomes])
+ def _finish(_):
+ try:
+ calendar = iComponent("VCALENDAR")
+ calendar.addProperty(iProperty("VERSION", "2.0"))
+ calendar.addProperty(iProperty("PRODID", iCalendarProductID))
- try:
- calendar = iComponent("VCALENDAR")
- calendar.addProperty(iProperty("VERSION", "2.0"))
- calendar.addProperty(iProperty("PRODID", iCalendarProductID))
+ uids = set()
+ tzids = set()
- uids = set()
- tzids = set()
+ for collection in collections:
+ for name, uid, type in collection.index().indexedSearch(None):
+ child = collection.getChild(name)
+ childData = child.iCalendarText()
- for collection in collections:
- for name, uid, type in collection.index().indexedSearch(None):
- child = collection.getChild(name)
- childData = child.iCalendarText()
+ try:
+ childCalendar = iComponent.fromString(childData)
+ except ValueError:
+ continue
+ assert childCalendar.name() == "VCALENDAR"
- try:
- childCalendar = iComponent.fromString(childData)
- except ValueError:
- continue
- assert childCalendar.name() == "VCALENDAR"
+ if uid in uids:
+ sys.stderr.write("Skipping duplicate event UID %r from %s\n" % (uid, collection.fp.path))
+ continue
+ else:
+ uids.add(uid)
- if uid in uids:
- sys.stderr.write("Skipping duplicate event UID %r from %s\n" % (uid, collection.fp.path))
- continue
- else:
- uids.add(uid)
+ for component in childCalendar.subcomponents():
+ # Only insert VTIMEZONEs once
+ if component.name() == "VTIMEZONE":
+ tzid = component.propertyValue("TZID")
+ if tzid in tzids:
+ continue
+ else:
+ tzids.add(tzid)
- for component in childCalendar.subcomponents():
- # Only insert VTIMEZONEs once
- if component.name() == "VTIMEZONE":
- tzid = component.propertyValue("TZID")
- if tzid in tzids:
- continue
- else:
- tzids.add(tzid)
+ calendar.addComponent(component)
- calendar.addComponent(component)
+ calendarData = str(calendar)
- calendarData = str(calendar)
+ if outputFileName:
+ try:
+ output = open(outputFileName, "w")
+ except IOError, e:
+ sys.stderr.write("Unable to open output file for writing %s: %s\n" % (outputFileName, e))
+ sys.exit(1)
+ else:
+ output = sys.stdout
- if outputFileName:
- try:
- output = open(outputFileName, "w")
- except IOError, e:
- sys.stderr.write("Unable to open output file for writing %s: %s\n" % (outputFileName, e))
- sys.exit(1)
- else:
- output = sys.stdout
+ output.write(calendarData)
- output.write(calendarData)
+ except UsageError, e:
+ usage(e)
+ return d.addCallback(_finish)
- except UsageError, e:
- usage(e)
-
if __name__ == "__main__":
main()
Modified: CalendarServer/branches/more-deferreds/calendarserver/tools/warmup.py
===================================================================
--- CalendarServer/branches/more-deferreds/calendarserver/tools/warmup.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/calendarserver/tools/warmup.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -33,6 +33,8 @@
from os.path import dirname, abspath
from twistedcaldav.config import ConfigurationError
+from twisted.internet.defer import gatherResults
+
from twistedcaldav.resource import isPseudoCalendarCollectionResource
from twistedcaldav.static import CalDAVFile, CalendarHomeFile
from twistedcaldav.directory.directory import DirectoryService
@@ -152,31 +154,38 @@
calendarCollections = set()
+ def _gotChildren(children):
+ for childName in children:
+ child = calendarHome.getChild(childName)
+ if isPseudoCalendarCollectionResource(child):
+ calendarCollections.add(child)
+ ds = []
for calendarHome in calendarHomes:
#print calendarHome
#sys.stdout.write("*")
readProperties(calendarHome)
- for childName in calendarHome.listChildren():
- child = calendarHome.getChild(childName)
- if isPseudoCalendarCollectionResource(child):
- calendarCollections.add(child)
+ ds.append(calendarHome.listChildren().addCallback(_gotChildren))
+ d = gatherResults(ds)
- for calendarCollection in calendarCollections:
- try:
- for name, uid, type in calendarCollection.index().indexedSearch(None):
- child = calendarCollection.getChild(name)
+ def _finish(_):
+ for calendarCollection in calendarCollections:
+ try:
+ for name, uid, type in calendarCollection.index().indexedSearch(None):
+ child = calendarCollection.getChild(name)
- #sys.stdout.write("+")
- childCalendar = child.iCalendarText()
+ #sys.stdout.write("+")
+ d = child.iCalendarText()
- readProperties(child)
+ readProperties(child)
- except sqlite3.OperationalError:
- # Outbox doesn't live on disk
- if calendarCollection.fp.basename() != "outbox":
- raise
+ except sqlite3.OperationalError:
+ # Outbox doesn't live on disk
+ if calendarCollection.fp.basename() != "outbox":
+ raise
+ return d.addCallback(_finish)
+
def readProperties(resource):
#sys.stdout.write("-")
for qname in resource.deadProperties().list():
Modified: CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.application.app.patch
===================================================================
--- CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.application.app.patch 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.application.app.patch 2009-07-16 00:37:50 UTC (rev 4462)
@@ -1,7 +1,6 @@
-Index: twisted/application/app.py
-===================================================================
---- twisted/application/app.py (revision 26969)
-+++ twisted/application/app.py (working copy)
+=== modified file 'twisted/application/app.py'
+--- twisted/application/app.py 2008-12-14 22:09:07 +0000
++++ twisted/application/app.py 2009-07-15 23:30:17 +0000
@@ -241,7 +241,11 @@
@param application: The application on which to check for an
L{ILogObserver}.
@@ -15,25 +14,24 @@
if observer is None:
observer = self._getLogObserver()
-@@ -408,9 +412,7 @@
+@@ -408,8 +412,6 @@
Run the application.
"""
self.preApplication()
- self.application = self.createOrGetApplication()
-
-
+
getLogObserverLegacy = getattr(self, 'getLogObserver', None)
if getLogObserverLegacy is not None:
- warnings.warn("Specifying a log observer with getLogObserver is "
-@@ -418,8 +420,10 @@
+@@ -418,7 +420,9 @@
category=DeprecationWarning)
self.startLogging(self.getLogObserver())
else:
- self.logger.start(self.application)
+ self.logger.start(None)
-
-+ self.application = self.createOrGetApplication()
+
++ self.application = self.createOrGetApplication()
+
self.postApplication()
self.logger.stop()
-
+
Modified: CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.mail.imap4.patch
===================================================================
--- CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.mail.imap4.patch 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.mail.imap4.patch 2009-07-16 00:37:50 UTC (rev 4462)
@@ -1,7 +1,6 @@
-Index: twisted/mail/imap4.py
-===================================================================
---- twisted/mail/imap4.py (revision 26969)
-+++ twisted/mail/imap4.py (working copy)
+=== modified file 'twisted/mail/imap4.py'
+--- twisted/mail/imap4.py 2009-03-23 11:02:59 +0000
++++ twisted/mail/imap4.py 2009-07-15 23:30:17 +0000
@@ -333,7 +333,7 @@
@@ -20,3 +19,4 @@
class MailboxException(IMAP4Exception): pass
+
Modified: CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.python.util.patch
===================================================================
--- CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.python.util.patch 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.python.util.patch 2009-07-16 00:37:50 UTC (rev 4462)
@@ -1,8 +1,7 @@
-Index: twisted/python/util.py
-===================================================================
---- twisted/python/util.py (revision 26969)
-+++ twisted/python/util.py (working copy)
-@@ -569,9 +569,29 @@
+=== modified file 'twisted/python/util.py'
+--- twisted/python/util.py 2009-03-30 13:33:33 +0000
++++ twisted/python/util.py 2009-07-15 23:30:18 +0000
+@@ -569,7 +569,27 @@
L2.sort()
return [e[2] for e in L2]
@@ -18,8 +17,8 @@
+if sys.platform == "darwin" and hasCtypes:
+ import pwd
+ libc = cdll.LoadLibrary(find_library("libc"))
- def initgroups(uid, primaryGid):
- """
++ def initgroups(uid, primaryGid):
++ """
+ Call initgroups with ctypes.
+ """
+ c_gid = c_int(primaryGid)
@@ -28,8 +27,7 @@
+ return libc.initgroups(c_username, c_gid)
+
+elif pwd is None or grp is None or setgroups is None or getgroups is None:
-+ def initgroups(uid, primaryGid):
-+ """
+ def initgroups(uid, primaryGid):
+ """
Do nothing.
-
- Underlying platform support require to manipulate groups is missing.
+
Modified: CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.auth.digest.patch
===================================================================
--- CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.auth.digest.patch 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.auth.digest.patch 2009-07-16 00:37:50 UTC (rev 4462)
@@ -1,7 +1,6 @@
-Index: twisted/web2/auth/digest.py
-===================================================================
---- twisted/web2/auth/digest.py (revision 26969)
-+++ twisted/web2/auth/digest.py (working copy)
+=== modified file 'twisted/web2/auth/digest.py'
+--- twisted/web2/auth/digest.py 2009-04-20 17:38:06 +0000
++++ twisted/web2/auth/digest.py 2009-07-15 23:30:18 +0000
@@ -138,11 +138,15 @@
implements(credentials.IUsernameHashedPassword,
IUsernameDigestHash)
@@ -19,7 +18,7 @@
def checkPassword(self, password):
response = self.fields.get('response')
-@@ -155,11 +159,23 @@
+@@ -155,10 +159,22 @@
expected = calcResponse(
calcHA1(algo, self.username, self.realm, password, nonce, cnonce),
@@ -30,7 +29,7 @@
- return expected == response
+ if expected == response:
+ return True
-
++
+ # IE7 sends cnonce and nc values, but auth fails if they are used.
+ # So try again without them...
+ # They can be omitted for backwards compatibility [RFC 2069].
@@ -41,10 +40,9 @@
+ )
+ if expected == response:
+ return True
-+
+
def checkHash(self, digestHash):
response = self.fields.get('response')
- uri = self.fields.get('uri')
@@ -171,7 +187,7 @@
expected = calcResponse(
@@ -80,3 +78,4 @@
+ self.realm,
+ auth,
+ originalMethod))
+
Modified: CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.method.report.patch
===================================================================
--- CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.method.report.patch 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.method.report.patch 2009-07-16 00:37:50 UTC (rev 4462)
@@ -1,7 +1,6 @@
-Index: twisted/web2/dav/method/report.py
-===================================================================
---- twisted/web2/dav/method/report.py (revision 26969)
-+++ twisted/web2/dav/method/report.py (working copy)
+=== modified file 'twisted/web2/dav/method/report.py'
+--- twisted/web2/dav/method/report.py 2009-04-20 17:38:06 +0000
++++ twisted/web2/dav/method/report.py 2009-07-15 23:30:18 +0000
@@ -94,8 +94,9 @@
namespace = doc.root_element.namespace
name = doc.root_element.name
@@ -32,3 +31,4 @@
try:
method = getattr(self, method_name)
+
Modified: CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.resource.patch
===================================================================
--- CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.resource.patch 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.resource.patch 2009-07-16 00:37:50 UTC (rev 4462)
@@ -1,7 +1,6 @@
-Index: twisted/web2/dav/resource.py
-===================================================================
---- twisted/web2/dav/resource.py (revision 26969)
-+++ twisted/web2/dav/resource.py (working copy)
+=== modified file 'twisted/web2/dav/resource.py'
+--- twisted/web2/dav/resource.py 2009-05-07 20:35:07 +0000
++++ twisted/web2/dav/resource.py 2009-07-15 23:30:18 +0000
@@ -49,12 +49,14 @@
if not hasattr(__builtin__, "frozenset"):
import sets.ImmutableSet as frozenset
@@ -19,7 +18,56 @@
from twisted.internet import reactor
from twisted.web2 import responsecode
from twisted.web2.http import HTTPError, RedirectResponse, StatusResponse
-@@ -642,41 +644,43 @@
+@@ -578,7 +580,6 @@
+
+ completionDeferred = Deferred()
+ basepath = request.urlForResource(self)
+- children = list(self.listChildren())
+
+ def checkPrivilegesError(failure):
+ failure.trap(AccessDeniedError)
+@@ -595,7 +596,7 @@
+ d.addCallback(lambda _: child)
+ return d
+
+- def gotChild(child, childpath):
++ def gotChild(child, childpath, children):
+ if child is None:
+ callback(None, childpath + "/")
+ else:
+@@ -603,14 +604,15 @@
+ callback(child, childpath + "/")
+ if depth == "infinity":
+ d = child.findChildren(depth, request, callback, privileges)
+- d.addCallback(lambda x: reactor.callLater(0, getChild))
++ d.addCallback(lambda x: reactor.callLater(0, getChild, children))
+ return d
+ else:
+ callback(child, childpath)
+
+- reactor.callLater(0, getChild)
++ reactor.callLater(0, getChild, children)
+
+- def getChild():
++ def getChild(children):
++ children = list(children)
+ try:
+ childname = children.pop()
+ except IndexError:
+@@ -619,10 +621,10 @@
+ childpath = joinURL(basepath, childname)
+ d = request.locateChildResource(self, childname)
+ d.addCallback(checkPrivileges)
+- d.addCallbacks(gotChild, checkPrivilegesError, (childpath,))
++ d.addCallbacks(gotChild, checkPrivilegesError, (childpath, children))
+ d.addErrback(completionDeferred.errback)
+
+- getChild()
++ self.listChildren().addCallback(getChild)
+
+ return completionDeferred
+
+@@ -642,39 +644,41 @@
# Authentication
##
@@ -49,10 +97,15 @@
- # "Authorization will not help" according to RFC2616
- #
- raise HTTPError(response)
-
+-
- d = self.checkPrivileges(request, privileges, recurse)
- d.addErrback(onErrors)
- return d
+-
+- d = maybeDeferred(self.authenticate, request)
+- d.addCallback(onAuth)
+- return d
++
+ try:
+ yield self.authenticate(request)
+ except (UnauthorizedLogin, LoginFailed), e:
@@ -62,10 +115,7 @@
+ request.remoteAddr
+ ))
+ raise HTTPError(response)
-
-- d = maybeDeferred(self.authenticate, request)
-- d.addCallback(onAuth)
-- return d
++
+ try:
+ yield self.checkPrivileges(request, privileges, recurse)
+ except AccessDeniedError, e:
@@ -84,12 +134,10 @@
+ # "Authorization will not help" according to RFC2616
+ #
+ raise HTTPError(response)
++
-+
def authenticate(self, request):
- if not (
- hasattr(request, 'portal') and
@@ -1880,7 +1884,7 @@
# If this is a collection and the URI doesn't end in "/", redirect.
#
@@ -99,3 +147,4 @@
def setHeaders(response):
response = IResponse(response)
+
Added: CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.static.patch
===================================================================
--- CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.static.patch (rev 0)
+++ CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.static.patch 2009-07-16 00:37:50 UTC (rev 4462)
@@ -0,0 +1,28 @@
+=== modified file 'twisted/web2/dav/static.py'
+--- twisted/web2/dav/static.py 2009-04-20 17:38:06 +0000
++++ twisted/web2/dav/static.py 2009-07-15 23:30:18 +0000
+@@ -53,6 +53,14 @@
+
+ Extends twisted.web2.static.File to handle WebDAV methods.
+ """
++ @classmethod
++ def fetch(cls, request, path, *args, **kwargs):
++ """
++ stuff etc
++ """
++ return succeed(cls(path, *args, **kwargs))
++
++
+ def __init__(
+ self, path,
+ defaultType="text/plain", indexNames=None,
+@@ -192,7 +200,7 @@
+ return (self.createSimilarFile(self.fp.child(path).path), segments[1:])
+
+ def createSimilarFile(self, path):
+- return self.__class__(
++ return self.__class__.fetch(None,
+ path, defaultType=self.defaultType, indexNames=self.indexNames[:],
+ principalCollections=self.principalCollections())
+
+
Added: CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.test.test_resource.patch
===================================================================
--- CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.test.test_resource.patch (rev 0)
+++ CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.test.test_resource.patch 2009-07-16 00:37:50 UTC (rev 4462)
@@ -0,0 +1,13 @@
+=== modified file 'twisted/web2/dav/test/test_resource.py'
+--- twisted/web2/dav/test/test_resource.py 2009-05-07 20:35:07 +0000
++++ twisted/web2/dav/test/test_resource.py 2009-07-15 23:30:18 +0000
+@@ -376,7 +376,7 @@
+ return self.children is not None
+
+ def listChildren(self):
+- return self.children.keys()
++ return succeed(self.children.keys())
+
+ def supportedPrivileges(self, request):
+ return succeed(davPrivilegeSet)
+
Added: CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch
===================================================================
--- CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch (rev 0)
+++ CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch 2009-07-16 00:37:50 UTC (rev 4462)
@@ -0,0 +1,20 @@
+=== modified file 'twisted/web2/dav/xattrprops.py'
+--- twisted/web2/dav/xattrprops.py 2009-06-03 23:46:41 +0000
++++ twisted/web2/dav/xattrprops.py 2009-07-15 23:30:18 +0000
+@@ -49,6 +49,7 @@
+
+ from twisted.python.util import untilConcludes
+ from twisted.python.failure import Failure
++from twisted.internet.defer import succeed
+ from twisted.python import log
+ from twisted.web2 import responsecode
+ from twisted.web2.http import HTTPError, StatusResponse
+@@ -188,6 +189,7 @@
+
+ # Update the resource because we've modified it
+ self.resource.fp.restat()
++ return succeed(None)
+
+
+ def delete(self, qname):
+
Modified: CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.error.patch
===================================================================
--- CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.error.patch 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.error.patch 2009-07-16 00:37:50 UTC (rev 4462)
@@ -1,7 +1,6 @@
-Index: twisted/web2/error.py
-===================================================================
---- twisted/web2/error.py (revision 26969)
-+++ twisted/web2/error.py (working copy)
+=== modified file 'twisted/web2/error.py'
+--- twisted/web2/error.py 2005-11-22 22:59:59 +0000
++++ twisted/web2/error.py 2009-07-15 23:30:18 +0000
@@ -92,7 +92,7 @@
"<body><h1>%s</h1>%s</body></html>") % (
response.code, title, title, message)
@@ -11,3 +10,4 @@
response.stream = stream.MemoryStream(body)
return response
+
Modified: CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.server.patch
===================================================================
--- CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.server.patch 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.server.patch 2009-07-16 00:37:50 UTC (rev 4462)
@@ -1,7 +1,6 @@
-Index: twisted/web2/server.py
-===================================================================
---- twisted/web2/server.py (revision 26969)
-+++ twisted/web2/server.py (working copy)
+=== modified file 'twisted/web2/server.py'
+--- twisted/web2/server.py 2009-04-20 17:38:06 +0000
++++ twisted/web2/server.py 2009-07-15 23:30:18 +0000
@@ -332,6 +332,16 @@
response = http.Response(responsecode.OK)
response.headers.setHeader('allow', ('GET', 'HEAD', 'OPTIONS', 'TRACE'))
@@ -19,3 +18,4 @@
# This is where CONNECT would go if we wanted it
return None
+
Added: CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.static.patch
===================================================================
--- CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.static.patch (rev 0)
+++ CalendarServer/branches/more-deferreds/lib-patches/Twisted/twisted.web2.static.patch 2009-07-16 00:37:50 UTC (rev 4462)
@@ -0,0 +1,69 @@
+=== modified file 'twisted/web2/static.py'
+--- twisted/web2/static.py 2009-04-20 17:38:06 +0000
++++ twisted/web2/static.py 2009-07-15 23:30:18 +0000
+@@ -16,7 +16,7 @@
+
+ # Twisted Imports
+ from twisted.python import filepath
+-from twisted.internet.defer import maybeDeferred
++from twisted.internet.defer import maybeDeferred, succeed
+ from zope.interface import implements
+
+ class MetaDataMixin(object):
+@@ -291,12 +291,13 @@
+ self.ignoredExts.append(ext)
+
+ def directoryListing(self):
+- return dirlist.DirectoryLister(self.fp.path,
+- self.listChildren(),
+- self.contentTypes,
+- self.contentEncodings,
+- self.defaultType)
+-
++ return self.listChildren().addCallback(lambda children: dirlist.DirectoryLister(
++ self.fp.path,
++ children,
++ self.contentTypes,
++ self.contentEncodings,
++ self.defaultType))
++
+ def putChild(self, name, child):
+ """
+ Register a child with the given name with this resource.
+@@ -329,7 +330,7 @@
+ children = self.putChildren.keys()
+ if self.fp.isdir():
+ children += [c for c in self.fp.listdir() if c not in children]
+- return children
++ return succeed(children)
+
+ def locateChild(self, req, segments):
+ """
+@@ -387,17 +388,17 @@
+ ifp = self.fp.childSearchPreauth(*self.indexNames)
+ if ifp:
+ # Render from the index file
+- standin = self.createSimilarFile(ifp.path)
++ standin = self.createSimilarFile(ifp.path).render(req)
+ else:
+ # Render from a DirectoryLister
+- standin = dirlist.DirectoryLister(
+- self.fp.path,
+- self.listChildren(),
+- self.contentTypes,
+- self.contentEncodings,
+- self.defaultType
+- )
+- return standin.render(req)
++ return self.listChildren().addCallback(
++ lambda children: dirlist.DirectoryLister(
++ self.fp.path,
++ self.listChildren(),
++ self.contentTypes,
++ self.contentEncodings,
++ self.defaultType
++ ).render(req))
+
+ try:
+ f = self.fp.open()
+
Modified: CalendarServer/branches/more-deferreds/twistedcaldav/directory/calendar.py
===================================================================
--- CalendarServer/branches/more-deferreds/twistedcaldav/directory/calendar.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/twistedcaldav/directory/calendar.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -102,7 +102,7 @@
return self.putChildren.get(name, None)
def listChildren(self):
- return self.directory.recordTypes()
+ return succeed(self.directory.recordTypes())
def principalCollections(self):
# FIXME: directory.principalCollection smells like a hack
@@ -172,10 +172,10 @@
for shortName in record.shortNames:
yield shortName
- return _recordShortnameExpand()
+ return succeed(_recordShortnameExpand())
else:
# Not a listable collection
- raise HTTPError(responsecode.FORBIDDEN)
+ return fail(HTTPError(responsecode.FORBIDDEN))
def createSimilarFile(self, path):
raise HTTPError(responsecode.NOT_FOUND)
@@ -227,7 +227,7 @@
def listChildren(self):
# Not a listable collection
- raise HTTPError(responsecode.FORBIDDEN)
+ return fail(HTTPError(responsecode.FORBIDDEN))
##
# DAV
Modified: CalendarServer/branches/more-deferreds/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/more-deferreds/twistedcaldav/directory/principal.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/twistedcaldav/directory/principal.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -37,7 +37,7 @@
from twisted.cred.credentials import UsernamePassword
from twisted.python.failure import Failure
from twisted.internet.defer import inlineCallbacks, returnValue
-from twisted.internet.defer import succeed
+from twisted.internet.defer import succeed, fail
from twisted.web2.auth.digest import DigestedCredentials
from twisted.web2 import responsecode
from twisted.web2.http import HTTPError
@@ -348,7 +348,7 @@
return self.putChildren.get(name, None)
def listChildren(self):
- return self.directory.recordTypes()
+ return succeed(self.directory.recordTypes())
##
# ACL
@@ -405,10 +405,10 @@
for shortName in record.shortNames:
yield shortName
- return _recordShortnameExpand()
+ return succeed(_recordShortnameExpand())
else:
# Not a listable collection
- raise HTTPError(responsecode.FORBIDDEN)
+ return fail(HTTPError(responsecode.FORBIDDEN))
##
# ACL
@@ -479,7 +479,7 @@
def listChildren(self):
# Not a listable collection
- raise HTTPError(responsecode.FORBIDDEN)
+ return fail(HTTPError(responsecode.FORBIDDEN))
##
# ACL
@@ -811,7 +811,7 @@
return None
def listChildren(self):
- return ()
+ return succeed(())
class DirectoryCalendarPrincipalResource (DirectoryPrincipalResource, CalendarPrincipalResource):
@@ -943,10 +943,9 @@
def listChildren(self):
if config.EnableProxyPrincipals:
- return ("calendar-proxy-read", "calendar-proxy-write")
+ return succeed(("calendar-proxy-read", "calendar-proxy-write"))
else:
- return ()
-
+ return succeed(())
##
# Utilities
##
Modified: CalendarServer/branches/more-deferreds/twistedcaldav/directory/test/test_principal.py
===================================================================
--- CalendarServer/branches/more-deferreds/twistedcaldav/directory/test/test_principal.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/twistedcaldav/directory/test/test_principal.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -105,34 +105,39 @@
principalCollections = provisioningResource.principalCollections()
self.assertEquals(set((provisioningURL,)), set(pc.principalCollectionURL() for pc in principalCollections))
- recordTypes = set(provisioningResource.listChildren())
- self.assertEquals(recordTypes, set(directory.recordTypes()))
+ d = provisioningResource.listChildren()
+ def _gotProvisioningChildren(children):
+ recordTypes = set(children)
+ self.assertEquals(recordTypes, set(directory.recordTypes()))
- for recordType in recordTypes:
- #print " -> %s" % (recordType,)
- typeResource = provisioningResource.getChild(recordType)
- self.failUnless(isinstance(typeResource, DirectoryPrincipalTypeProvisioningResource))
+ for recordType in recordTypes:
+ #print " -> %s" % (recordType,)
+ typeResource = provisioningResource.getChild(recordType)
+ self.failUnless(isinstance(typeResource, DirectoryPrincipalTypeProvisioningResource))
- typeURL = provisioningURL + recordType + "/"
- self.assertEquals(typeURL, typeResource.principalCollectionURL())
+ typeURL = provisioningURL + recordType + "/"
+ self.assertEquals(typeURL, typeResource.principalCollectionURL())
- principalCollections = typeResource.principalCollections()
- self.assertEquals(set((provisioningURL,)), set(pc.principalCollectionURL() for pc in principalCollections))
+ principalCollections = typeResource.principalCollections()
+ self.assertEquals(set((provisioningURL,)), set(pc.principalCollectionURL() for pc in principalCollections))
+ d = typeResource.listChildren()
+ def _gotTypeChildren(children):
+ shortNames = set(children)
+ self.assertEquals(shortNames, set(r.shortNames[0] for r in directory.listRecords(recordType)))
- shortNames = set(typeResource.listChildren())
- self.assertEquals(shortNames, set(r.shortNames[0] for r in directory.listRecords(recordType)))
+ for shortName in shortNames:
+ #print " -> %s" % (shortName,)
+ recordResource = typeResource.getChild(shortName)
+ self.failUnless(isinstance(recordResource, DirectoryPrincipalResource))
- for shortName in shortNames:
- #print " -> %s" % (shortName,)
- recordResource = typeResource.getChild(shortName)
- self.failUnless(isinstance(recordResource, DirectoryPrincipalResource))
+ recordURL = typeURL + shortName + "/"
+ self.assertIn(recordURL, (recordResource.principalURL(),) + tuple(recordResource.alternateURIs()))
- recordURL = typeURL + shortName + "/"
- self.assertIn(recordURL, (recordResource.principalURL(),) + tuple(recordResource.alternateURIs()))
+ principalCollections = recordResource.principalCollections()
+ self.assertEquals(set((provisioningURL,)), set(pc.principalCollectionURL() for pc in principalCollections))
+
+ return d.addCallback(_gotProvisioningChildren)
- principalCollections = recordResource.principalCollections()
- self.assertEquals(set((provisioningURL,)), set(pc.principalCollectionURL() for pc in principalCollections))
-
def test_allRecords(self):
"""
Test of a test routine...
@@ -405,8 +410,8 @@
for args in _authReadOnlyPrivileges(self, provisioningResource, provisioningResource.principalCollectionURL()):
yield self._checkPrivileges(*args)
-
- for recordType in provisioningResource.listChildren():
+ children = yield provisioningResource.listChildren()
+ for recordType in children:
#print " -> %s" % (recordType,)
typeResource = provisioningResource.getChild(recordType)
Modified: CalendarServer/branches/more-deferreds/twistedcaldav/extensions.py
===================================================================
--- CalendarServer/branches/more-deferreds/twistedcaldav/extensions.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/twistedcaldav/extensions.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -529,7 +529,7 @@
children = []
basepath = request.urlForResource(self)
- childnames = list(self.listChildren())
+ childnames = yield self.listChildren()
for childname in childnames:
if names and childname not in names:
continue
@@ -880,37 +880,39 @@
]
even = Alternator()
- for name in sorted(self.listChildren()):
- child = self.getChild(name)
+ d = self.listChildren()
+ def _gotChildren(children):
+ for name in sorted(children):
+ child = self.getChild(name)
- url, name, size, lastModified, contentType = self.getChildDirectoryEntry(child, name)
+ url, name, size, lastModified, contentType = self.getChildDirectoryEntry(child, name)
- # FIXME: gray out resources that are not readable
+ # FIXME: gray out resources that are not readable
+ output.append(
+ """<tr class="%(even)s">"""
+ """<td><a href="%(url)s">%(name)s</a></td>"""
+ """<td align="right">%(size)s</td>"""
+ """<td>%(lastModified)s</td>"""
+ """<td>%(type)s</td>"""
+ """</tr>"""
+ % {
+ "even": even.state() and "even" or "odd",
+ "url": url,
+ "name": cgi.escape(name),
+ "size": size,
+ "lastModified": lastModified,
+ "type": contentType,
+ }
+ )
+
output.append(
- """<tr class="%(even)s">"""
- """<td><a href="%(url)s">%(name)s</a></td>"""
- """<td align="right">%(size)s</td>"""
- """<td>%(lastModified)s</td>"""
- """<td>%(type)s</td>"""
- """</tr>"""
- % {
- "even": even.state() and "even" or "odd",
- "url": url,
- "name": cgi.escape(name),
- "size": size,
- "lastModified": lastModified,
- "type": contentType,
- }
+ """</table></div>"""
+ """<div class="directory-listing">"""
+ """<h1>Properties</h1>"""
+ """<table>"""
+ """<tr><th>Name</th> <th>Value</th></tr>"""
)
- output.append(
- """</table></div>"""
- """<div class="directory-listing">"""
- """<h1>Properties</h1>"""
- """<table>"""
- """<tr><th>Name</th> <th>Value</th></tr>"""
- )
-
def gotProperties(qnames):
ds = []
@@ -986,9 +988,10 @@
d = DeferredList(ds)
d.addCallback(gotValues)
return d
-
- d = self.listProperties(request)
- d.addCallback(gotProperties)
+ d.addCallback(
+ _gotChildren).addCallback(
+ lambda _: self.listProperties(request)).addCallback(
+ gotProperties)
return d
def getChildDirectoryEntry(self, child, name):
@@ -1116,6 +1119,7 @@
cache[property.qname()] = None
self.propertyStore.set(property)
cache[property.qname()] = property
+ return succeed(None)
def contains(self, qname):
#self.log_debug("Contains: %r, %r" % (self.resource.fp.path, qname))
Modified: CalendarServer/branches/more-deferreds/twistedcaldav/index.py
===================================================================
--- CalendarServer/branches/more-deferreds/twistedcaldav/index.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/twistedcaldav/index.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -305,15 +305,16 @@
rowiter = self._db_execute("select DISTINCT RESOURCE.NAME, RESOURCE.UID, RESOURCE.TYPE" + qualifiers[0], *qualifiers[1])
# Check result for missing resources
-
+ rows = []
for row in rowiter:
name = row[0]
if self.resource.getChild(name.encode("utf-8")):
- yield row
+ rows.append(row)
else:
log.err("Calendar resource %s is missing from %s. Removing from index."
% (name, self.resource))
self.deleteResource(name)
+ return succeed(rows)
def bruteForceSearch(self):
"""
@@ -324,17 +325,17 @@
rowiter = self._db_execute("select NAME, UID, TYPE from RESOURCE")
# Check result for missing resources:
-
+ rows = []
for row in rowiter:
name = row[0]
if self.resource.getChild(name.encode("utf-8")):
- yield row
+ rows.append(row)
else:
log.err("Calendar resource %s is missing from %s. Removing from index."
% (name, self.resource))
self.deleteResource(name)
+ return succeed(rows)
-
def _db_version(self):
"""
@return: the schema version assigned to this index.
@@ -744,8 +745,8 @@
@return: True if the UID is not in the index and is not reserved,
False otherwise.
"""
- rname = yield self.resourceNameForUID(uid) # TODO: Check in callers to isAllowedUID, change this to an inlineCallBack
- returnValue(rname is None or rname in names)
+ return self.resourceNameForUID(uid).addCallback(
+ lambda rname: rname is None or rname in names)
def _db_type(self):
"""
@@ -856,7 +857,7 @@
"""
# iTIP does not require unique UIDs
- return True
+ return succeed(True)
def _db_type(self):
"""
Modified: CalendarServer/branches/more-deferreds/twistedcaldav/method/delete_common.py
===================================================================
--- CalendarServer/branches/more-deferreds/twistedcaldav/method/delete_common.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/twistedcaldav/method/delete_common.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -205,8 +205,9 @@
errors = ResponseQueue(deluri, "DELETE", responsecode.NO_CONTENT)
- for childname in delresource.listChildren():
+ children = yield delresource.listChildren()
+ for childname in children:
childurl = joinURL(deluri, childname)
child = (yield self.request.locateChildResource(delresource, childname))
Modified: CalendarServer/branches/more-deferreds/twistedcaldav/method/report_common.py
===================================================================
--- CalendarServer/branches/more-deferreds/twistedcaldav/method/report_common.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/twistedcaldav/method/report_common.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -349,24 +349,20 @@
filteredaces = (yield calresource.inheritedACEsforChildren(request))
try:
- resources = calresource.index().indexedSearch(filter)
+ resources = yield calresource.index().indexedSearch(filter)
except IndexedSearchException:
- resources = calresource.index().bruteForceSearch()
+ resources = yield calresource.index().bruteForceSearch()
for name, uid, type in resources: #@UnusedVariable
-
# Check privileges - must have at least CalDAV:read-free-busy
child = (yield request.locateChildResource(calresource, name))
-
# TODO: for server-to-server we bypass this right now as we have no way to authorize external users.
if not servertoserver:
try:
yield child.checkPrivileges(request, (caldavxml.ReadFreeBusy(),), inherited_aces=filteredaces)
except AccessDeniedError:
continue
-
- calendar = calresource.iCalendar(name)
-
+ calendar = yield calresource.iCalendar(name)
# The calendar may come back as None if the resource is being changed, or was deleted
# between our initial index query and getting here. For now we will ignore this error, but in
# the longer term we need to implement some form of locking, perhaps.
Modified: CalendarServer/branches/more-deferreds/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/more-deferreds/twistedcaldav/resource.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/twistedcaldav/resource.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -501,18 +501,18 @@
ca.addCallback(lambda ign: child)
return ca
- def gotChild(child, childpath):
+ def gotChild(child, childpath, children):
if child.isCalendarCollection():
callback(child, childpath)
elif child.isCollection():
if depth == "infinity":
fc = child.findCalendarCollections(depth, request, callback, privileges)
- fc.addCallback(lambda x: reactor.callLater(0, getChild))
+ fc.addCallback(lambda x: reactor.callLater(0, getChild, children))
return fc
- reactor.callLater(0, getChild)
+ reactor.callLater(0, getChild, children)
- def getChild():
+ def getChild(children):
try:
childname = children.pop()
except IndexError:
@@ -521,15 +521,14 @@
childpath = joinURL(basepath, childname)
child = request.locateResource(childpath)
child.addCallback(checkPrivileges)
- child.addCallbacks(gotChild, checkPrivilegesError, (childpath,))
+ child.addCallbacks(gotChild, checkPrivilegesError, (childpath,), children)
child.addErrback(completionDeferred.errback)
completionDeferred = Deferred()
if depth != "0" and self.isCollection():
basepath = request.urlForResource(self)
- children = self.listChildren()
- getChild()
+ self.listChildren().addCallback(getChild)
else:
completionDeferred.callback(None)
Modified: CalendarServer/branches/more-deferreds/twistedcaldav/static.py
===================================================================
--- CalendarServer/branches/more-deferreds/twistedcaldav/static.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/twistedcaldav/static.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -387,10 +387,9 @@
##
def listChildren(self):
- return [
- child for child in super(CalDAVFile, self).listChildren()
- if not child.startswith(".")
- ]
+ return super(CalDAVFile, self).listChildren().addCallback(
+ lambda children: [child for child in children
+ if not child.startswith(".")])
def propertyCollection(self):
if not hasattr(self, "_propertyCollection"):
@@ -550,12 +549,13 @@
class AutoProvisioningFileMixIn (AutoProvisioningResourceMixIn):
def provision(self):
- return self.provisionFile()
+ d = self.provisionFile()
+ super(AutoProvisioningFileMixIn, self).provision()
+ return d
-
def provisionFile(self, request=None):
if hasattr(self, "_provisioned_file"):
- return False
+ return succeed(False)
else:
self._provisioned_file = True
Modified: CalendarServer/branches/more-deferreds/twistedcaldav/test/test_collectioncontents.py
===================================================================
--- CalendarServer/branches/more-deferreds/twistedcaldav/test/test_collectioncontents.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/twistedcaldav/test/test_collectioncontents.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -192,9 +192,11 @@
fd.close()
fd = open(os.path.join(colpath, "bogus"), "w")
fd.close()
- children = self.site.resource.listChildren()
- self.assertTrue("bogus" in children)
- self.assertFalse("._bogus" in children)
+ d = self.site.resource.listChildren()
+ def _gotChildren(children):
+ self.assertTrue("bogus" in children)
+ self.assertFalse("._bogus" in children)
+ return d.addCallback(_gotChildren)
def test_fail_dot_file_put_in_calendar(self):
"""
Modified: CalendarServer/branches/more-deferreds/twistedcaldav/test/test_sql.py
===================================================================
--- CalendarServer/branches/more-deferreds/twistedcaldav/test/test_sql.py 2009-07-15 01:34:59 UTC (rev 4461)
+++ CalendarServer/branches/more-deferreds/twistedcaldav/test/test_sql.py 2009-07-16 00:37:50 UTC (rev 4462)
@@ -182,9 +182,11 @@
fd.close()
fd = open(os.path.join(colpath, "test"), "w")
fd.close()
- children = self.site.resource.listChildren()
- self.assertTrue("test" in children)
- self.assertFalse(db_prefix + "sqlite" in children)
+ d = self.site.resource.listChildren()
+ def _gotChildren(children):
+ self.assertTrue("test" in children)
+ self.assertFalse(db_prefix + "sqlite" in children)
+ return d.addCallback(_gotChildren)
def test_duplicate_create(self):
dbname = self.mktemp()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090715/49d67462/attachment-0001.html>
More information about the calendarserver-changes
mailing list