[CalendarServer-changes] [6334] CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/ method

source_changes at macosforge.org source_changes at macosforge.org
Tue Sep 21 18:16:05 PDT 2010


Revision: 6334
          http://trac.macosforge.org/projects/calendarserver/changeset/6334
Author:   glyph at apple.com
Date:     2010-09-21 18:16:04 -0700 (Tue, 21 Sep 2010)
Log Message:
-----------
bubble up resourceUIDForName

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/method/put_addressbook_common.py
    CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/method/put_common.py

Modified: CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/method/put_addressbook_common.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/method/put_addressbook_common.py	2010-09-22 00:00:35 UTC (rev 6333)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/method/put_addressbook_common.py	2010-09-22 01:16:04 UTC (rev 6334)
@@ -25,7 +25,7 @@
 from twisted.internet import reactor
 from twisted.python.failure import Failure
 
-from twisted.internet.defer import Deferred, inlineCallbacks, succeed
+from twisted.internet.defer import Deferred, inlineCallbacks
 from twisted.internet.defer import returnValue
 from twext.web2 import responsecode
 from twext.web2.dav import davxml
@@ -149,6 +149,8 @@
         
         self.access = None
 
+
+    @inlineCallbacks
     def fullValidation(self):
         """
         Do full validation of source and destination vcard data.
@@ -191,7 +193,7 @@
             else:
                 # Get UID from original resource
                 self.source_index = self.sourceparent.index()
-                self.uid = self.source_index.resourceUIDForName(self.source.name())
+                self.uid = yield self.source_index.resourceUIDForName(self.source.name())
                 if self.uid is None:
                     log.err("Source vcard does not have a UID: %s" % self.source.name())
                     raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "valid-addressbook-object-resource")))
@@ -207,7 +209,7 @@
                 raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "max-resource-size")))
 
             # Check access
-            return succeed(None)
+            returnValue(None)
     
     def validResourceName(self):
         """
@@ -271,6 +273,8 @@
 
         return result, message
 
+
+    @inlineCallbacks
     def noUIDConflict(self, uid):
         """
         Check that the UID of the new vcard object conforms to the requirements of
@@ -305,14 +309,15 @@
         else:
             # Cannot overwrite a resource with different UID
             if self.destination.exists():
-                olduid = index.resourceUIDForName(self.destination.name())
+                olduid = yield index.resourceUIDForName(self.destination.name())
                 if olduid != uid:
                     rname = self.destination.name()
                     result = False
                     message = "Cannot overwrite vcard resource %s with different UID %s" % (rname, olduid)
         
-        return result, message, rname
+        returnValue((result, message, rname))
 
+
     @inlineCallbacks
     def checkQuota(self):
         """
@@ -436,7 +441,7 @@
             
                 # UID conflict check - note we do this after reserving the UID to avoid a race condition where two requests
                 # try to write the same vcard data to two different resource URIs.
-                result, message, rname = self.noUIDConflict(self.uid)
+                result, message, rname = yield self.noUIDConflict(self.uid)
                 if not result:
                     log.err(message)
                     raise HTTPError(ErrorResponse(responsecode.FORBIDDEN,

Modified: CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/method/put_common.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/method/put_common.py	2010-09-22 00:00:35 UTC (rev 6333)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/method/put_common.py	2010-09-22 01:16:04 UTC (rev 6334)
@@ -280,7 +280,7 @@
             else:
                 # Get UID from original resource
                 self.source_index = self.sourceparent.index()
-                self.uid = self.source_index.resourceUIDForName(self.source.name())
+                self.uid = yield self.source_index.resourceUIDForName(self.source.name())
                 if self.uid is None:
                     log.err("Source calendar does not have a UID: %s" % self.source)
                     raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-object-resource")))
@@ -573,6 +573,7 @@
         returnValue(new_has_private_comments)
 
 
+    @inlineCallbacks
     def noUIDConflict(self, uid): 
         """ 
         Check that the UID of the new calendar object conforms to the requirements of 
@@ -586,7 +587,7 @@
         result = True 
         message = "" 
         rname = "" 
-        
+
         # Adjust for a move into same calendar collection 
         oldname = None 
         if self.sourceparent and (self.sourceparent == self.destinationparent) and self.deletesource: 
@@ -606,16 +607,15 @@
         else: 
             # Cannot overwrite a resource with different UID 
             if self.destination.exists(): 
-                olduid = index.resourceUIDForName(self.destination.name()) 
+                olduid = yield index.resourceUIDForName(self.destination.name()) 
                 if olduid != uid: 
                     rname = self.destination.name() 
                     result = False 
                     message = "Cannot overwrite calendar resource %s with different UID %s" % (rname, olduid) 
          
-        return result, message, rname 
+        returnValue((result, message, rname))
 
 
-
     @inlineCallbacks
     def doImplicitScheduling(self):
 
@@ -830,7 +830,7 @@
                 # UID conflict check - note we do this after reserving the UID to avoid a race condition where two requests 
                 # try to write the same calendar data to two different resource URIs. 
                 if not self.isiTIP: 
-                    result, message, rname = self.noUIDConflict(self.uid) 
+                    result, message, rname = yield self.noUIDConflict(self.uid) 
                     if not result: 
                         log.err(message)
                         raise HTTPError(ErrorResponse(responsecode.FORBIDDEN,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100921/a99051a5/attachment.html>


More information about the calendarserver-changes mailing list