[CalendarServer-changes] [5566] CalendarServer/branches/users/wsanchez/transations/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Tue May 4 17:05:16 PDT 2010


Revision: 5566
          http://trac.macosforge.org/projects/calendarserver/changeset/5566
Author:   glyph at apple.com
Date:     2010-05-04 17:05:15 -0700 (Tue, 04 May 2010)
Log Message:
-----------
Propagate down to the calendar object level (in the 'already exists' case, at least).

Modified Paths:
--------------
    CalendarServer/branches/users/wsanchez/transations/twistedcaldav/static.py
    CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_wrapping.py

Modified: CalendarServer/branches/users/wsanchez/transations/twistedcaldav/static.py
===================================================================
--- CalendarServer/branches/users/wsanchez/transations/twistedcaldav/static.py	2010-05-05 00:02:56 UTC (rev 5565)
+++ CalendarServer/branches/users/wsanchez/transations/twistedcaldav/static.py	2010-05-05 00:05:15 UTC (rev 5566)
@@ -623,10 +623,12 @@
         similar = super(CalDAVFile, self).createSimilarFile(path)
 
         if isCalendarCollectionResource(self):
+            similar._newStoreObject = \
+                self._newStoreCalendar.calendarObjectWithName(path.basename())
 
             # Short-circuit stat with information we know to be true at this point
             if isinstance(path, FilePath) and hasattr(self, "knownChildren"):
-                if os.path.basename(path.path) in self.knownChildren:
+                if path.basename() in self.knownChildren:
                     path.existsCached = True
                     path.isDirCached = False
 

Modified: CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_wrapping.py
===================================================================
--- CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_wrapping.py	2010-05-05 00:02:56 UTC (rev 5565)
+++ CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_wrapping.py	2010-05-05 00:05:15 UTC (rev 5566)
@@ -13,7 +13,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 ##
-
 """
 Tests for the interaction between model-level and protocol-level logic.
 """
@@ -24,13 +23,15 @@
 from twistedcaldav.config import config
 from twistedcaldav.directory import augment
 from twistedcaldav.directory.calendar import uidsResourceName
-from twistedcaldav.directory.principal import \
-    DirectoryPrincipalProvisioningResource
+from twistedcaldav.directory.principal import (
+    DirectoryPrincipalProvisioningResource)
 from twistedcaldav.directory.test.test_xmlfile import augmentsFile, xmlFile
 from twistedcaldav.directory.xmlfile import XMLDirectoryService
 from twistedcaldav.static import CalendarHomeProvisioningFile
 from twistedcaldav.test.util import TestCase
 from txcaldav.calendarstore.file import CalendarStore, CalendarHome
+from txcaldav.calendarstore.test.test_file import event4_text
+from twistedcaldav.ical import Component as VComponent
 
 
 
@@ -68,6 +69,33 @@
         self.site.resource.setAccessControlList(davxml.ACL())
 
 
+    def populateOneObject(self, objectName, objectText):
+        """
+        Populate one calendar object in the test user's calendar.
+
+        @param objectName: The name of a calendar object.
+        @type objectName: str
+        @param objectText: Some iCalendar text to populate it with.
+        @type objectText: str 
+        """
+        record = self.directoryService.recordWithShortName("users", "wsanchez")
+        uid = record.uid
+        # XXX there should be a more test-friendly way to ensure the directory
+        # actually exists
+        try:
+            self.calendarCollection._newStore._path.createDirectory()
+        except:
+            pass
+        txn = self.calendarCollection._newStore.newTransaction()
+        home = txn.calendarHomeWithUID(uid, True)
+        cal = home.calendarWithName("calendar")
+        if cal is None:
+            home.createCalendarWithName("calendar")
+            cal = home.calendarWithName("calendar")
+        cal.createCalendarObjectWithName(objectName, VComponent.fromString(objectText))
+        txn.commit()
+
+
     @inlineCallbacks
     def getResource(self, path):
         """
@@ -133,3 +161,18 @@
             self.assertIdentical(
                 getattr(calDavFile, "_newStoreCalendar", None), None
             )
+
+
+    @inlineCallbacks
+    def test_lookupCalendarObject(self):
+        """
+        When a L{CalDAVFile} representing an existing calendar object is looked
+        up on a L{CalDAVFile} representing a calendar collection, a parallel
+        L{CalendarObject} will be created (with a matching FilePath).
+        """
+        self.populateOneObject("1.ics", event4_text)
+        calDavFileCalendar = yield self.getResource(
+            "calendars/users/wsanchez/calendar/1.ics"
+        )
+        self.assertEquals(calDavFileCalendar._newStoreObject._path, 
+                          calDavFileCalendar.fp)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100504/c5394c79/attachment.html>


More information about the calendarserver-changes mailing list