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

source_changes at macosforge.org source_changes at macosforge.org
Fri Aug 25 11:29:11 PDT 2006


Revision: 66
Author:   cdaboo at apple.com
Date:     2006-08-25 11:29:09 -0700 (Fri, 25 Aug 2006)

Log Message:
-----------
Used deferred properly.

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-25 17:50:13 UTC (rev 65)
+++ CalendarServer/branches/users/cdaboo/acl-merge/twistedcaldav/static.py	2006-08-25 18:29:09 UTC (rev 66)
@@ -167,31 +167,29 @@
         #
         # 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)
+        def _deferOK(result):
+            if result != responsecode.CREATED:
+                raise HTTPError(result)
     
             self.writeDeadProperty(davxml.ResourceType.calendar)
-
-        except:
-            f = Failure()
-    
+            return responsecode.CREATED
+        
+        def _deferErr(f):
             try:
                 rmdir(self.fp)
             except Exception, e:
                 log.err("Unable to clean up after failed MKCALENDAR: %s" % e)
     
             if isinstance(f.value, HTTPError):
-                return fail(f.value.response)
+                return f.value.response
     
             f.raiseException()
-    
-        return succeed(responsecode.CREATED)
-
+            
+        d = mkcollection(self.fp)
+        d.addCallback(_deferOK)
+        d.addErrback(_deferErr)
+        return d
+ 
     def iCalendar(self, name=None, request=None):
         if self.isPseudoCalendarCollection():
             if name is None:

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


More information about the calendarserver-changes mailing list