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

source_changes at macosforge.org source_changes at macosforge.org
Tue Sep 21 16:38:43 PDT 2010


Revision: 6332
          http://trac.macosforge.org/projects/calendarserver/changeset/6332
Author:   glyph at apple.com
Date:     2010-09-21 16:38:39 -0700 (Tue, 21 Sep 2010)
Log Message:
-----------
make inNewTransaction async, to prepare for calendarObjectWithName being async (as verified by implicitauto1) 

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/scheduling/processing.py
    CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/scheduling/utils.py
    CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/storebridge.py

Modified: CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/scheduling/processing.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/scheduling/processing.py	2010-09-21 22:35:48 UTC (rev 6331)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/scheduling/processing.py	2010-09-21 23:38:39 UTC (rev 6332)
@@ -422,7 +422,7 @@
 
         @param calendar: calendar data to examine
         @type calendar: L{Component}
-        
+
         @return: L{Component} for the new calendar data to write
         """
         

Modified: CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/scheduling/utils.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/scheduling/utils.py	2010-09-21 22:35:48 UTC (rev 6331)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/scheduling/utils.py	2010-09-21 23:38:39 UTC (rev 6332)
@@ -14,7 +14,7 @@
 # limitations under the License.
 ##
 
-from twisted.internet.defer import inlineCallbacks, returnValue, succeed
+from twisted.internet.defer import inlineCallbacks, returnValue
 from twistedcaldav.method import report_common
 from twext.web2.dav.util import joinURL
 
@@ -23,7 +23,7 @@
     """
     Get a copy of the event for a principal.
     """
-    
+
     result = {
         "resource": None,
         "resource_name": None,
@@ -34,32 +34,37 @@
     if principal and principal.locallyHosted():
         # Get principal's calendar-home
         calendar_home = principal.calendarHome(request)
-        
-        # FIXME: because of the URL->resource request mapping thing, we have to force the request
-        # to recognize this resource
+
+        # FIXME: because of the URL->resource request mapping thing, we have to
+        # force the request to recognize this resource.
         request._rememberResource(calendar_home, calendar_home.url())
 
-        # Run a UID query against the UID
+        # Run a UID query against the UID.
+        @inlineCallbacks
         def queryCalendarCollection(collection, uri):
             if not allow_shared:
                 if collection.isVirtualShare():
-                    return succeed(True)
+                    returnValue(True)
 
-            rname = collection.index().resourceNameForUID(uid)
+            rname = yield collection.index().resourceNameForUID(uid)
             if rname:
-                resource = collection.getChild(rname)
+                resource = yield collection.getChild(rname)
                 request._rememberResource(resource, joinURL(uri, rname))
 
                 result["resource"] = resource
                 result["resource_name"] = rname
                 result["calendar_collection"] = collection
                 result["calendar_collection_uri"] = uri
-                return succeed(False)
+                returnValue(False)
             else:
-                return succeed(True)
-        
-        # NB We are by-passing privilege checking here. That should be OK as the data found is not
-        # exposed to the user.
-        yield report_common.applyToCalendarCollections(calendar_home, request, calendar_home.url(), "infinity", queryCalendarCollection, None)
+                returnValue(True)
 
+        # NB We are by-passing privilege checking here. That should be OK as
+        # the data found is not exposed to the user.
+        yield report_common.applyToCalendarCollections(
+            calendar_home, request, calendar_home.url(),
+            "infinity", queryCalendarCollection, None
+        )
+
     returnValue((result["resource"], result["resource_name"], result["calendar_collection"], result["calendar_collection_uri"],))
+

Modified: CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/storebridge.py	2010-09-21 22:35:48 UTC (rev 6331)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/storebridge.py	2010-09-21 23:38:39 UTC (rev 6332)
@@ -250,13 +250,15 @@
         self._initializeWithCalendar(calendar, home)
 
 
+    @inlineCallbacks
     def makeChild(self, name):
         """
-        Create a L{CalendarObjectResource} or L{ProtoCalendarObjectResource} based on a
-        path object.
+        Create a L{CalendarObjectResource} or L{ProtoCalendarObjectResource}
+        based on a calendar object name.
         """
 
-        newStoreObject = self._newStoreCalendar.calendarObjectWithName(name)
+        cal = self._newStoreCalendar
+        newStoreObject = yield cal.calendarObjectWithName(name)
 
         if newStoreObject is not None:
             similar = CalendarObjectResource(
@@ -264,20 +266,15 @@
                 principalCollections=self._principalCollections
             )
         else:
-            # FIXME: creation in http_PUT should talk to a specific resource
-            # type; this is the domain of StoreCalendarObjectResource.
-            # similar = ProtoCalendarObjectFile(self._newStoreCalendar, path)
             similar = ProtoCalendarObjectResource(
-                self._newStoreCalendar,
-                name,
+                cal, name,
                 principalCollections=self._principalCollections
             )
 
-        # FIXME: tests should be failing without this line.
-        # Specifically, http_PUT won't be committing its transaction properly.
         self.propagateTransaction(similar)
-        return similar
+        returnValue(similar)
 
+
     def listChildren(self):
         """
         @return: a sequence of the names of all known children of this resource.
@@ -967,17 +964,17 @@
         self._initializeWithObject(calendarObject)
 
 
+    @inlineCallbacks
     def inNewTransaction(self, request):
         """
         Implicit auto-replies need to span multiple transactions.  Clean out
         the given request's resource-lookup mapping, transaction, and re-look-
-        up my calendar object in a new transaction.
+        up this L{CalendarObjectResource}'s calendar object in a new
+        transaction.
 
-        @return: the new transaction so it can be committed.
+        @return: a Deferred which fires with the new transaction, so it can be
+            committed.
         """
-        # FIXME: private names from 'file' implementation; maybe there should
-        # be a public way to do this?  or maybe we should just have a real
-        # queue.
         objectName = self._newStoreObject.name()
         calendar = self._newStoreObject.calendar()
         calendarName = calendar.name()
@@ -985,14 +982,14 @@
         homeUID = ownerHome.uid()
         txn = ownerHome.transaction().store().newTransaction(
             "new transaction for " + self._newStoreObject.name())
-        newObject = (txn.calendarHomeWithUID(homeUID)
-                        .calendarWithName(calendarName)
-                        .calendarObjectWithName(objectName))
+        newObject = ((yield (yield (yield txn.calendarHomeWithUID(homeUID))
+                             .calendarWithName(calendarName))
+                             .calendarObjectWithName(objectName)))
         request._newStoreTransaction = txn
         request._resourcesByURL.clear()
         request._urlsByResource.clear()
         self._initializeWithObject(newObject)
-        return txn
+        returnValue(txn)
 
 
     def isCollection(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100921/7ca9c6f1/attachment.html>


More information about the calendarserver-changes mailing list