[CalendarServer-changes] [61] CalendarServer/branches/users/cdaboo/acl-merge/twistedcaldav/static.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Aug 24 13:23:42 PDT 2006


Revision: 61
Author:   cdaboo at apple.com
Date:     2006-08-24 13:23:40 -0700 (Thu, 24 Aug 2006)

Log Message:
-----------
Make it deferred friendly.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/acl-merge/twistedcaldav/static.py

Modified: CalendarServer/branches/users/cdaboo/acl-merge/twistedcaldav/static.py
===================================================================
--- CalendarServer/branches/users/cdaboo/acl-merge/twistedcaldav/static.py	2006-08-24 20:20:14 UTC (rev 60)
+++ CalendarServer/branches/users/cdaboo/acl-merge/twistedcaldav/static.py	2006-08-24 20:23:40 UTC (rev 61)
@@ -37,6 +37,9 @@
 import errno
 from urlparse import urlsplit
 
+from twisted.internet.defer import fail
+from twisted.internet.defer import succeed
+from twisted.internet.defer import waitForDeferred
 from twisted.python import log
 from twisted.python.failure import Failure
 from twisted.python.filepath import FilePath
@@ -163,7 +166,11 @@
         # Create the collection once we know it is safe to do so
         #
         try:
+            # We do not yield this as mkcollection executes immediately with a result,
+            # plus this method is a deferredGenerator and thus can only return Deferreds
             r = mkcollection(self.fp)
+            assert r.called
+            r = r.result
             if r != responsecode.CREATED: raise HTTPError(r)
     
             self.writeDeadProperty(davxml.ResourceType.calendar)
@@ -176,11 +183,12 @@
             except Exception, e:
                 log.err("Unable to clean up after failed MKCALENDAR: %s" % e)
     
-            if isinstance(f.value, HTTPError): return f.value.response
+            if isinstance(f.value, HTTPError):
+                return fail(f.value.response)
     
             f.raiseException()
     
-        return responsecode.CREATED
+        return succeed(responsecode.CREATED)
 
     def iCalendar(self, name=None, request=None):
         if self.isPseudoCalendarCollection():
@@ -769,7 +777,9 @@
             child = CalDAVFile(os.path.join(home.fp.path, calendar))
             child_exists = child.exists()
             if not child_exists:
-                child.createCalendarCollection()
+                c = child.createCalendarCollection()
+                assert c.called
+                c = c.result
             calendars.append(childURL)
             if (resetacl or not child_exists):
                 child.setAccessControlList(

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


More information about the calendarserver-changes mailing list