[CalendarServer-changes] [6048] CalendarServer/branches/users/glyph/sql-store

source_changes at macosforge.org source_changes at macosforge.org
Wed Aug 11 09:00:28 PDT 2010


Revision: 6048
          http://trac.macosforge.org/projects/calendarserver/changeset/6048
Author:   glyph at apple.com
Date:     2010-08-11 09:00:27 -0700 (Wed, 11 Aug 2010)
Log Message:
-----------
'breadcrumb' API to walk back up the tree in the cases where we need to identify an object in a new transaction using public APIs; remove AddressBookObjectResource.inNewTransaction since addressbooks don't do implicit scheduling and thus don't require it.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/sql-store/twistedcaldav/storebridge.py
    CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/file.py
    CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/postgres.py
    CalendarServer/branches/users/glyph/sql-store/txcaldav/icalendarstore.py
    CalendarServer/branches/users/glyph/sql-store/txcarddav/addressbookstore/file.py
    CalendarServer/branches/users/glyph/sql-store/txcarddav/iaddressbookstore.py
    CalendarServer/branches/users/glyph/sql-store/txdav/idav.py

Modified: CalendarServer/branches/users/glyph/sql-store/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/twistedcaldav/storebridge.py	2010-08-11 15:26:46 UTC (rev 6047)
+++ CalendarServer/branches/users/glyph/sql-store/twistedcaldav/storebridge.py	2010-08-11 16:00:27 UTC (rev 6048)
@@ -944,16 +944,18 @@
         the given request's resource-lookup mapping, transaction, and re-look-
         up my calendar object in a new transaction.
 
-        Return the new transaction so it can be committed.
+        @return: 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()
-        calendarName = self._newStoreObject._calendar.name()
-        homeUID = self._newStoreObject._calendar._calendarHome.uid()
-        store = self._newStoreObject._transaction.store()
-        txn = store.newTransaction("new transaction for " + self._newStoreObject.name())
+        calendar = self._newStoreObject.calendar()
+        calendarName = calendar.name()
+        ownerHome = calendar.ownerCalendarHome()
+        homeUID = ownerHome.uid()
+        txn = ownerHome.transaction().store().newTransaction(
+            "new transaction for " + self._newStoreObject.name())
         newObject = (txn.calendarHomeWithUID(homeUID)
                         .calendarWithName(calendarName)
                         .calendarObjectWithName(objectName))
@@ -1551,34 +1553,10 @@
         self._initializeWithObject(Object)
 
 
-    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
-        addressbook object in a new transaction.
-
-        Return 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()
-        Name = self._newStoreObject._addressbook.name()
-        homeUID = self._newStoreObject._addressbook._addressbookHome.uid()
-        store = self._newStoreObject._transaction.store()
-        txn = store.newTransaction("new AB transaction for " + self._newStoreObject.name())
-        newObject = (txn.addressbookHomeWithUID(homeUID)
-                        .addressbookWithName(Name)
-                        .addressbookObjectWithName(objectName))
-        request._newStoreTransaction = txn
-        request._resourcesByURL.clear()
-        request._urlsByResource.clear()
-        self._initializeWithObject(newObject)
-        return txn
-
-
     def isCollection(self):
         return False
 
+
     def exists(self):
         # FIXME: Tests
         return True

Modified: CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/file.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/file.py	2010-08-11 15:26:46 UTC (rev 6047)
+++ CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/file.py	2010-08-11 16:00:27 UTC (rev 6048)
@@ -222,6 +222,10 @@
         return self._parentCollection
 
 
+    def calendar(self):
+        return self._calendar
+
+
     @writeOperation
     def setComponent(self, component):
         validateCalendarComponent(self, self._calendar, component)

Modified: CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/postgres.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/postgres.py	2010-08-11 15:26:46 UTC (rev 6047)
+++ CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/postgres.py	2010-08-11 16:00:27 UTC (rev 6048)
@@ -229,6 +229,10 @@
         return self._name
 
 
+    def calendar(self):
+        return self._calendar
+
+
     def iCalendarText(self):
         if self._calendarText is None:
             text = self._txn.execSQL(
@@ -1032,6 +1036,10 @@
         return self.uid()
 
 
+    def transaction(self):
+        return self._txn
+
+
     def listChildren(self):
         """
         Retrieve the names of the children in this calendar home.
@@ -1392,6 +1400,10 @@
         self._label = label
 
 
+    def store(self):
+        return self._store
+
+
     def __repr__(self):
         return 'PG-TXN<%s>' % (self._label,)
 
@@ -1538,6 +1550,10 @@
         return self._name
 
 
+    def addressbook(self):
+        return self._addressbook
+
+
     def vCardText(self):
         if self._vCardText is None:
             text = self._txn.execSQL(

Modified: CalendarServer/branches/users/glyph/sql-store/txcaldav/icalendarstore.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/txcaldav/icalendarstore.py	2010-08-11 15:26:46 UTC (rev 6047)
+++ CalendarServer/branches/users/glyph/sql-store/txcaldav/icalendarstore.py	2010-08-11 16:00:27 UTC (rev 6048)
@@ -265,6 +265,12 @@
     object.
     """
 
+    def calendar():
+        """
+        @return: The calendar which this calendar object is a part of.
+        @rtype: L{ICalendar}
+        """
+
     def setComponent(component):
         """
         Rewrite this calendar object to match the given C{component}.

Modified: CalendarServer/branches/users/glyph/sql-store/txcarddav/addressbookstore/file.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/txcarddav/addressbookstore/file.py	2010-08-11 15:26:46 UTC (rev 6047)
+++ CalendarServer/branches/users/glyph/sql-store/txcarddav/addressbookstore/file.py	2010-08-11 16:00:27 UTC (rev 6048)
@@ -152,6 +152,11 @@
     def _addressbook(self):
         return self._parentCollection
 
+
+    def addressbook(self):
+        return self._addressbook
+
+
     @writeOperation
     def setComponent(self, component):
         if not isinstance(component, VComponent):

Modified: CalendarServer/branches/users/glyph/sql-store/txcarddav/iaddressbookstore.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/txcarddav/iaddressbookstore.py	2010-08-11 15:26:46 UTC (rev 6047)
+++ CalendarServer/branches/users/glyph/sql-store/txcarddav/iaddressbookstore.py	2010-08-11 16:00:27 UTC (rev 6048)
@@ -1,3 +1,4 @@
+# -*- test-case-name: txcarddav.addressbookstore,txcaldav.calendarstore.test.test_postgres.AddressBookSQLStorageTests -*-
 ##
 # Copyright (c) 2010 Apple Inc. All rights reserved.
 #
@@ -222,6 +223,13 @@
     An addressbook object describes a contact (vCard).
     """
 
+    def addressbook():
+        """
+        @return: The address book which this address book object is a part of.
+        @rtype: L{IAddressBook}
+        """
+
+
     def setComponent(component):
         """
         Rewrite this addressbook object to match the given C{component}.

Modified: CalendarServer/branches/users/glyph/sql-store/txdav/idav.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/txdav/idav.py	2010-08-11 15:26:46 UTC (rev 6047)
+++ CalendarServer/branches/users/glyph/sql-store/txdav/idav.py	2010-08-11 16:00:27 UTC (rev 6048)
@@ -68,7 +68,7 @@
     Property name.
     """
     namespace = Attribute("Namespace")
-    name      = Attribute("Name")
+    name = Attribute("Name")
 
     def toString():
         """
@@ -118,7 +118,7 @@
     """
     An L{IDataStoreResource} are the objects stored in an L{IDataStore}.
     """
-    
+
     def name():
         """
         Identify the name of the object
@@ -169,7 +169,9 @@
 
         @return: an L{IPropertyStore}.
         """
-    
+
+
+
 class ITransaction(Interface):
     """
     Transaction that can be aborted and either succeeds or fails in
@@ -205,6 +207,16 @@
         @param operation: a callable.
         """
 
+
+    def store():
+        """
+        The store that this transaction was initiated from.
+
+        @rtype: L{IDataStore}
+        """
+
+
+
 class INotifier(Interface):
     """
     Push notification interface
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100811/6f6f7843/attachment-0001.html>


More information about the calendarserver-changes mailing list