[CalendarServer-changes] [6219] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Aug 31 14:55:54 PDT 2010


Revision: 6219
          http://trac.macosforge.org/projects/calendarserver/changeset/6219
Author:   sagen at apple.com
Date:     2010-08-31 14:55:53 -0700 (Tue, 31 Aug 2010)
Log Message:
-----------
Use a transaction when injecting IMIP replies so they'll get committed.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tap/util.py
    CalendarServer/trunk/twistedcaldav/mail.py
    CalendarServer/trunk/twistedcaldav/resource.py

Modified: CalendarServer/trunk/calendarserver/tap/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/util.py	2010-08-31 20:30:08 UTC (rev 6218)
+++ CalendarServer/trunk/calendarserver/tap/util.py	2010-08-31 21:55:53 UTC (rev 6219)
@@ -449,7 +449,7 @@
         for path, cls, args, scheme in resources:
 
             # putChild doesn't want "/" starting the path
-            root.putChild(path, cls(root, *args))
+            root.putChild(path, cls(root, _newStore, *args))
 
             # overrides requires "/" prepended
             path = "/" + path

Modified: CalendarServer/trunk/twistedcaldav/mail.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/mail.py	2010-08-31 20:30:08 UTC (rev 6218)
+++ CalendarServer/trunk/twistedcaldav/mail.py	2010-08-31 21:55:53 UTC (rev 6219)
@@ -58,6 +58,7 @@
 from twistedcaldav import ical, caldavxml
 from twistedcaldav import memcachepool
 from twistedcaldav.config import config
+from twistedcaldav.directory.util import transactionFromRequest
 from twistedcaldav.ical import Property
 from twistedcaldav.localization import translationTo
 from twistedcaldav.resource import CalDAVResource
@@ -180,15 +181,17 @@
     Extends L{DAVResource} to provide IMIP delivery functionality.
     """
 
-    def __init__(self, parent):
+    def __init__(self, parent, store):
         """
         @param parent: the parent resource of this one.
+        @param store: the store to use for transactions.
         """
         assert parent is not None
 
         CalDAVResource.__init__(self, principalCollections=parent.principalCollections())
 
         self.parent = parent
+        self._newStore = store
 
 
     def accessControlList(self, request, inheritance=True,
@@ -290,6 +293,14 @@
 
 class IMIPReplyInboxResource(IMIPInboxResource):
 
+    def renderHTTP(self, request):
+        """
+        Set up a transaction which will be used and committed by implicit
+        scheduling.
+        """
+        txn = transactionFromRequest(request, self._newStore)
+        return super(IMIPReplyInboxResource, self).renderHTTP(request, txn)
+
     @inlineCallbacks
     def http_POST(self, request):
         """
@@ -309,8 +320,8 @@
 
 class IMIPInvitationInboxResource(IMIPInboxResource):
 
-    def __init__(self, parent, mailer):
-        super(IMIPInvitationInboxResource, self).__init__(parent)
+    def __init__(self, parent, store, mailer):
+        super(IMIPInvitationInboxResource, self).__init__(parent, store)
         self.mailer = mailer
 
     @inlineCallbacks

Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py	2010-08-31 20:30:08 UTC (rev 6218)
+++ CalendarServer/trunk/twistedcaldav/resource.py	2010-08-31 21:55:53 UTC (rev 6219)
@@ -273,23 +273,27 @@
         self._transactionError = True
 
 
-    def renderHTTP(self, request):
+    def renderHTTP(self, request, transaction=None):
         """
         Override C{renderHTTP} to commit the transaction when the resource is
         successfully rendered.
 
         @param request: the request to generate a response for.
         @type request: L{twext.web2.iweb.IRequest}
+        @param transaction: optional transaction to use instead of associated transaction
+        @type transaction: L{txdav.caldav.idav.ITransaction}
         """
         d = maybeDeferred(super(CalDAVResource, self).renderHTTP, request)
-        def succeeded(result):
-            if self._associatedTransaction is not None:
+        def succeeded(result, transaction=None):
+            if transaction is None:
+                transaction = self._associatedTransaction
+            if transaction is not None:
                 if self._transactionError:
-                    self._associatedTransaction.abort()
+                    transaction.abort()
                 else:
-                    self._associatedTransaction.commit()
+                    transaction.commit()
             return result
-        return d.addCallback(succeeded)
+        return d.addCallback(succeeded, transaction=transaction)
 
 
     # Begin transitional new-store resource interface:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100831/04f955e3/attachment.html>


More information about the calendarserver-changes mailing list