[CalendarServer-changes] [4227] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Mon May 11 12:05:22 PDT 2009
Revision: 4227
http://trac.macosforge.org/projects/calendarserver/changeset/4227
Author: cdaboo at apple.com
Date: 2009-05-11 12:05:22 -0700 (Mon, 11 May 2009)
Log Message:
-----------
Handle the case where we migrate calendar data from an earlier server that does not support implicit
scheduling and we need to detect proper scheduling resources.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/customxml.py
CalendarServer/trunk/twistedcaldav/method/put_common.py
CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
Modified: CalendarServer/trunk/twistedcaldav/customxml.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/customxml.py 2009-05-11 18:46:57 UTC (rev 4226)
+++ CalendarServer/trunk/twistedcaldav/customxml.py 2009-05-11 19:05:22 UTC (rev 4227)
@@ -64,7 +64,7 @@
def getValue(self):
return str(self)
-class TwistedSchedulingObjectResource (davxml.WebDAVEmptyElement):
+class TwistedSchedulingObjectResource (davxml.WebDAVTextElement):
"""
Indicates that the resource is a scheduling object resource.
"""
Modified: CalendarServer/trunk/twistedcaldav/method/put_common.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/put_common.py 2009-05-11 18:46:57 UTC (rev 4226)
+++ CalendarServer/trunk/twistedcaldav/method/put_common.py 2009-05-11 19:05:22 UTC (rev 4227)
@@ -1005,7 +1005,7 @@
# Check for scheduling object resource and write property
if is_scheduling_resource:
- self.destination.writeDeadProperty(TwistedSchedulingObjectResource())
+ self.destination.writeDeadProperty(TwistedSchedulingObjectResource.fromString("true"))
# Need to figure out when to change the schedule tag:
#
@@ -1049,7 +1049,7 @@
else:
self.destination.removeDeadProperty(TwistedScheduleMatchETags)
else:
- self.destination.removeDeadProperty(TwistedSchedulingObjectResource)
+ self.destination.writeDeadProperty(TwistedSchedulingObjectResource.fromString("false"))
self.destination.removeDeadProperty(ScheduleTag)
self.destination.removeDeadProperty(TwistedScheduleMatchETags)
Modified: CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/implicit.py 2009-05-11 18:46:57 UTC (rev 4226)
+++ CalendarServer/trunk/twistedcaldav/scheduling/implicit.py 2009-05-11 19:05:22 UTC (rev 4227)
@@ -68,7 +68,7 @@
self.internal_request = internal_request
existing_resource = resource.exists()
- existing_type = "schedule" if existing_resource and resource.hasDeadProperty(TwistedSchedulingObjectResource()) else "calendar"
+ existing_type = "schedule" if self.checkSchedulingObjectResource(resource) else "calendar"
new_type = "schedule" if (yield self.checkImplicitState()) else "calendar"
if existing_type == "calendar":
@@ -105,8 +105,8 @@
new_type = "schedule" if (yield self.checkImplicitState()) else "calendar"
dest_exists = destresource.exists()
- dest_is_implicit = destresource.hasDeadProperty(TwistedSchedulingObjectResource()) if dest_exists else False
- src_is_implicit = srcresource.hasDeadProperty(TwistedSchedulingObjectResource()) or new_type == "schedule"
+ dest_is_implicit = self.checkSchedulingObjectResource(destresource)
+ src_is_implicit = self.checkSchedulingObjectResource(srcresource) or new_type == "schedule"
if srccal and destcal:
if src_is_implicit and dest_exists or dest_is_implicit:
@@ -135,9 +135,8 @@
new_type = "schedule" if (yield self.checkImplicitState()) else "calendar"
- dest_exists = destresource.exists()
- dest_is_implicit = destresource.hasDeadProperty(TwistedSchedulingObjectResource()) if dest_exists else False
- src_is_implicit = srcresource.hasDeadProperty(TwistedSchedulingObjectResource()) or new_type == "schedule"
+ dest_is_implicit = self.checkSchedulingObjectResource(destresource)
+ src_is_implicit = self.checkSchedulingObjectResource(srcresource) or new_type == "schedule"
if srccal and destcal:
if src_is_implicit or dest_is_implicit:
@@ -165,11 +164,38 @@
yield self.checkImplicitState()
- resource_type = "schedule" if resource.hasDeadProperty(TwistedSchedulingObjectResource()) else "calendar"
+ resource_type = "schedule" if self.checkSchedulingObjectResource(resource) else "calendar"
self.action = "remove" if resource_type == "schedule" else "none"
returnValue((self.action != "none", False,))
+ def checkSchedulingObjectResource(self, resource):
+
+ if resource and resource.exists():
+ try:
+ implicit = resource.readDeadProperty(TwistedSchedulingObjectResource)
+ except HTTPError:
+ implicit = None
+ if implicit is not None:
+ return implicit != "false"
+ else:
+ calendar = resource.iCalendar()
+ # Get the ORGANIZER and verify it is the same for all components
+ try:
+ organizer = calendar.validOrganizerForScheduling()
+ except ValueError:
+ # We have different ORGANIZERs in the same iCalendar object - this is an error
+ return False
+ organizerPrincipal = resource.principalForCalendarUserAddress(organizer) if organizer else None
+ resource.writeDeadProperty(TwistedSchedulingObjectResource("true" if organizerPrincipal != None else "false"))
+ log.debug("Implicit - checked scheduling object resource state for UID: '%s', result: %s" % (
+ calendar.resourceUID(),
+ "true" if organizerPrincipal != None else "false",
+ ))
+ return organizerPrincipal != None
+
+ return False
+
@inlineCallbacks
def checkImplicitState(self):
# Get some useful information from the calendar
@@ -357,7 +383,7 @@
child = (yield self.request.locateResource(joinURL(collection_uri, rname)))
if child == check_resource:
returnValue(True)
- matched_type = "schedule" if child and child.hasDeadProperty(TwistedSchedulingObjectResource()) else "calendar"
+ matched_type = "schedule" if self.checkSchedulingObjectResource(child) else "calendar"
if (
collection_uri != check_parent_uri and
(type == "schedule" or matched_type == "schedule")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090511/134247c5/attachment.html>
More information about the calendarserver-changes
mailing list