[CalendarServer-changes] [8697] CalendarServer/branches/users/glyph/migrate-merge
source_changes at macosforge.org
source_changes at macosforge.org
Thu Feb 16 04:28:52 PST 2012
Revision: 8697
http://trac.macosforge.org/projects/calendarserver/changeset/8697
Author: glyph at apple.com
Date: 2012-02-16 04:28:52 -0800 (Thu, 16 Feb 2012)
Log Message:
-----------
Basic calendar merge functionality; tests should pass.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/migrate-merge/txdav/caldav/datastore/util.py
Property Changed:
----------------
CalendarServer/branches/users/glyph/migrate-merge/
Modified: CalendarServer/branches/users/glyph/migrate-merge/txdav/caldav/datastore/util.py
===================================================================
--- CalendarServer/branches/users/glyph/migrate-merge/txdav/caldav/datastore/util.py 2012-02-16 12:28:48 UTC (rev 8696)
+++ CalendarServer/branches/users/glyph/migrate-merge/txdav/caldav/datastore/util.py 2012-02-16 12:28:52 UTC (rev 8697)
@@ -32,8 +32,12 @@
from twistedcaldav.datafilters.privateevents import PrivateEventFilter
from txdav.caldav.icalendarstore import IAttachmentStorageTransport
-from txdav.common.icommondatastore import InvalidObjectResourceError, NoSuchObjectResourceError, InternalDataStoreError
+from txdav.common.icommondatastore import (
+ InvalidObjectResourceError, NoSuchObjectResourceError,
+ InternalDataStoreError, HomeChildNameAlreadyExistsError
+)
+
from zope.interface.declarations import implements
import os
@@ -279,10 +283,11 @@
@inlineCallbacks
-def migrateHome(inHome, outHome, getComponent=lambda x: x.component()):
+def migrateHome(inHome, outHome, getComponent=lambda x: x.component(),
+ merge=False):
"""
- Copy all calendars and properties in the given input calendar to the given
- output calendar.
+ Copy all calendars and properties in the given input calendar home to the
+ given output calendar home.
@param inHome: the L{ICalendarHome} to retrieve calendars and properties
from.
@@ -293,6 +298,13 @@
@param getComponent: a 1-argument callable that takes an L{ICalendarObject}
(from a calendar in C{inHome}) and returns a L{VComponent} (to store in
a calendar in outHome).
+
+ @param merge: a boolean indicating whether to raise an exception when
+ encounting a conflicting element of data (calendar or event), or to
+ attempt to merge them together.
+
+ @return: a L{Deferred} that fires with C{None} when the migration is
+ complete.
"""
yield outHome.removeCalendarWithName("calendar")
if config.RestrictCalendarsToOneComponentType:
@@ -304,12 +316,17 @@
name = calendar.name()
if name == "outbox":
continue
- yield outHome.createCalendarWithName(name)
+ d = outHome.createCalendarWithName(name)
+ if merge:
+ d.addErrback(lambda f: f.trap(HomeChildNameAlreadyExistsError))
+ yield d
outCalendar = yield outHome.calendarWithName(name)
try:
yield _migrateCalendar(calendar, outCalendar, getComponent)
except InternalDataStoreError:
- log.error(" Failed to migrate calendar: %s/%s" % (inHome.name(), name,))
+ log.error(
+ " Failed to migrate calendar: %s/%s" % (inHome.name(), name,)
+ )
# No migration for notifications, since they weren't present in earlier
# released versions of CalendarServer.
@@ -318,6 +335,8 @@
if config.RestrictCalendarsToOneComponentType:
yield outHome.splitCalendars()
+
+
class CalendarObjectBase(object):
"""
Base logic shared between file- and sql-based L{ICalendarObject}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120216/7320544a/attachment-0001.html>
More information about the calendarserver-changes
mailing list