[CalendarServer-changes] [5681] CalendarServer/branches/new-store/txcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jun 4 11:01:23 PDT 2010
Revision: 5681
http://trac.macosforge.org/projects/calendarserver/changeset/5681
Author: glyph at apple.com
Date: 2010-06-04 11:01:18 -0700 (Fri, 04 Jun 2010)
Log Message:
-----------
basic rename() method for calendars
Modified Paths:
--------------
CalendarServer/branches/new-store/txcaldav/calendarstore/file.py
CalendarServer/branches/new-store/txcaldav/calendarstore/test/common.py
CalendarServer/branches/new-store/txcaldav/icalendarstore.py
Modified: CalendarServer/branches/new-store/txcaldav/calendarstore/file.py
===================================================================
--- CalendarServer/branches/new-store/txcaldav/calendarstore/file.py 2010-06-04 17:29:19 UTC (rev 5680)
+++ CalendarServer/branches/new-store/txcaldav/calendarstore/file.py 2010-06-04 18:01:18 UTC (rev 5681)
@@ -396,9 +396,25 @@
def name(self):
+ if self._renamedName is not None:
+ return self._renamedName
return self._path.basename()
+ _renamedName = None
+
+ def rename(self, name):
+ oldName = self.name()
+ self._renamedName = name
+ self._calendarHome
+ self._calendarHome._newCalendars[name] = self
+ self._calendarHome._removedCalendars.add(oldName)
+ def doIt():
+ self._path.moveTo(self._path.sibling(name))
+ return lambda : None # FIXME: revert
+ self._transaction.addOperation(doIt)
+
+
def ownerCalendarHome(self):
return self._calendarHome
Modified: CalendarServer/branches/new-store/txcaldav/calendarstore/test/common.py
===================================================================
--- CalendarServer/branches/new-store/txcaldav/calendarstore/test/common.py 2010-06-04 17:29:19 UTC (rev 5680)
+++ CalendarServer/branches/new-store/txcaldav/calendarstore/test/common.py 2010-06-04 18:01:18 UTC (rev 5681)
@@ -316,6 +316,27 @@
self.assertEquals(calendar.name(), name)
+ def test_calendarRename(self):
+ """
+ L{ICalendar.rename} changes the name of the L{ICalendar}.
+ """
+ home = self.homeUnderTest()
+ calendar = home.calendarWithName("calendar_1")
+ calendar.rename("some_other_name")
+ def positiveAssertions():
+ self.assertEquals(calendar.name(), "some_other_name")
+ self.assertEquals(calendar, home.calendarWithName("some_other_name"))
+ self.assertEquals(None, home.calendarWithName("calendar_1"))
+ positiveAssertions()
+ self.commit()
+ home = self.homeUnderTest()
+ calendar = home.calendarWithName("some_other_name")
+ positiveAssertions()
+ # FIXME: revert
+ # FIXME: test for multiple renames
+ # FIXME: test for conflicting renames (a->b, c->a in the same txn)
+
+
def test_calendarWithName_absent(self):
"""
L{ICalendarHome.calendarWithName} returns C{None} for calendars which
Modified: CalendarServer/branches/new-store/txcaldav/icalendarstore.py
===================================================================
--- CalendarServer/branches/new-store/txcaldav/icalendarstore.py 2010-06-04 17:29:19 UTC (rev 5680)
+++ CalendarServer/branches/new-store/txcaldav/icalendarstore.py 2010-06-04 18:01:18 UTC (rev 5681)
@@ -238,6 +238,11 @@
@rtype: C{str}
"""
+ def rename(name):
+ """
+ Change the name of this calendar.
+ """
+
def ownerCalendarHome():
"""
Retrieve the calendar home for the owner of this calendar.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100604/26a045cf/attachment.html>
More information about the calendarserver-changes
mailing list