[CalendarServer-changes] [5040] CalendarServer/trunk/txcaldav/calendarstore

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 3 15:30:35 PST 2010


Revision: 5040
          http://trac.macosforge.org/projects/calendarserver/changeset/5040
Author:   wsanchez at apple.com
Date:     2010-02-03 15:30:35 -0800 (Wed, 03 Feb 2010)
Log Message:
-----------
More file store

Modified Paths:
--------------
    CalendarServer/trunk/txcaldav/calendarstore/file.py
    CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py

Modified: CalendarServer/trunk/txcaldav/calendarstore/file.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/file.py	2010-02-03 23:28:55 UTC (rev 5039)
+++ CalendarServer/trunk/txcaldav/calendarstore/file.py	2010-02-03 23:30:35 UTC (rev 5040)
@@ -159,19 +159,52 @@
     def __repr__(self):
         return "<%s: %s>" % (self.__class__.__name__, self.path.path)
 
+    def index(self):
+        #
+        # OK, here's where we get ugly.
+        # The index code needs to be rewritten also, but in the meantime...
+        #
+        class StubResource(object):
+            """
+            Just enough resource to keep the Index class going.
+            """
+            def __init__(self, calendar):
+                self.calendar = calendar
+                self.fp = self.calendar.path
+
+            def getChild(self, name):
+                # None if no child... else child needs to support .iCalendar()
+                raise NotImplementedError()
+
+            def bumpSyncToken(self, xxx):
+                raise NotImplementedError()
+
+        if not hasattr(self, "_index"):
+            self._index = Index(StubResource(self))
+        return self._index
+
     def name(self):
         return self.path.basename()
 
     def ownerCalendarHome(self):
         return self.calendarHome
 
-    def calendarObjects(self):
+    def _calendarObjects_index(self):
+        for name, uid, componentType in self.index().bruteForceSearch():
+            calendarObject = self.calendarObjectWithName(name)
+            calendarObject._uid = uid
+            calendarObject._componentType = componentType
+
+
+    def _calendarObjects_listdir(self):
         return (
             self.calendarObjectWithName(name)
             for name in self.path.listdir()
             if not name.startswith(".")
         )
 
+    calendarObjects = _calendarObjects_index
+
     def calendarObjectWithName(self, name):
         childPath = self.path.child(name)
         if childPath.isfile():
@@ -238,6 +271,13 @@
         if not isinstance(component, iComponent):
             raise TypeError(iComponent)
 
+        if component.resourceUID() != self.uid():
+            raise InvalidCalendarComponentError(
+                "UID may not change (%s != %s)" % (
+                    component.resourceUID(), self.uid()
+                 )
+            )
+
         try:
             component.validateForCalDAV()
         except InvalidICalendarDataError, e:

Modified: CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py	2010-02-03 23:28:55 UTC (rev 5039)
+++ CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py	2010-02-03 23:30:35 UTC (rev 5040)
@@ -647,13 +647,12 @@
         calendarObject = self.calendar1.calendarObjectWithName("1.ics")
         self.assertEquals(calendarObject.component(), component)
 
-    @featureUnimplemented
     def test_setComponent_uidchanged(self):
         component = iComponent.fromString(event4_text)
 
         calendarObject = self.calendar1.calendarObjectWithName("1.ics")
         self.assertRaises(
-            CalendarObjectUIDAlreadyExistsError,
+            InvalidCalendarComponentError,
             calendarObject.setComponent, component
         )
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100203/1173daf4/attachment.html>


More information about the calendarserver-changes mailing list