[CalendarServer-changes] [3066] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Fri Sep 26 09:19:15 PDT 2008
Revision: 3066
http://trac.macosforge.org/projects/calendarserver/changeset/3066
Author: cdaboo at apple.com
Date: 2008-09-26 09:19:13 -0700 (Fri, 26 Sep 2008)
Log Message:
-----------
Make sure private events can be implicitly scheduled.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/ical.py
CalendarServer/trunk/twistedcaldav/method/put_common.py
CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py
CalendarServer/trunk/twistedcaldav/scheduling/itip.py
CalendarServer/trunk/twistedcaldav/scheduling/processing.py
Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py 2008-09-26 04:23:13 UTC (rev 3065)
+++ CalendarServer/trunk/twistedcaldav/ical.py 2008-09-26 16:19:13 UTC (rev 3066)
@@ -1387,20 +1387,21 @@
if component.name() == "VALARM":
self.removeComponent(component)
- def filterProperties(self, remove=None, keep=None):
+ def filterProperties(self, remove=None, keep=None, do_subcomponents=True):
"""
Remove all properties that do not match the provided set.
"""
- assert self.name() == "VCALENDAR", "Not a calendar: %r" % (self,)
-
- for component in self.subcomponents():
- if component.name() == "VTIMEZONE":
- continue
+ if do_subcomponents:
+ for component in self.subcomponents():
+ component.filterProperties(remove, keep, do_subcomponents=False)
+ else:
+ if self.name() == "VTIMEZONE":
+ return
if keep:
- [component.removeProperty(p) for p in tuple(component.properties()) if p.name() not in keep]
+ [self.removeProperty(p) for p in tuple(self.properties()) if p.name() not in keep]
if remove:
- [component.removeProperty(p) for p in tuple(component.properties()) if p.name() in remove]
+ [self.removeProperty(p) for p in tuple(self.properties()) if p.name() in remove]
def removeXProperties(self, keep_properties=()):
"""
Modified: CalendarServer/trunk/twistedcaldav/method/put_common.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/put_common.py 2008-09-26 04:23:13 UTC (rev 3065)
+++ CalendarServer/trunk/twistedcaldav/method/put_common.py 2008-09-26 16:19:13 UTC (rev 3066)
@@ -409,17 +409,18 @@
raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (calendarserver_namespace, "valid-access-restriction")))
# Only DAV:owner is able to set the property to other than PUBLIC
- def _callback(parent_owner):
-
- authz = self.destinationparent.currentPrincipal(self.request)
- if davxml.Principal(parent_owner) != authz and self.access != Component.ACCESS_PUBLIC:
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (calendarserver_namespace, "valid-access-restriction-change")))
-
- return None
-
- d = self.destinationparent.owner(self.request)
- d.addCallback(_callback)
- return d
+ if not self.internal_request:
+ def _callback(parent_owner):
+
+ authz = self.destinationparent.currentPrincipal(self.request)
+ if davxml.Principal(parent_owner) != authz and self.access != Component.ACCESS_PUBLIC:
+ raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (calendarserver_namespace, "valid-access-restriction-change")))
+
+ return None
+
+ d = self.destinationparent.owner(self.request)
+ d.addCallback(_callback)
+ return d
else:
# Check whether an access property was present before and write that into the calendar data
if not self.source and self.destination.exists() and self.destination.hasDeadProperty(TwistedCalendarAccessProperty):
Modified: CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py 2008-09-26 04:23:13 UTC (rev 3065)
+++ CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py 2008-09-26 16:19:13 UTC (rev 3066)
@@ -50,35 +50,24 @@
changed by an organizer. Basically any change except for anything related to a VALARM.
"""
- removeProperties = (
- "CREATED",
- "DTSTAMP",
- "LAST-MODIFIED",
- )
-
- removeAttendeeParameters = (
- "SCHEDULE-AGENT",
- "SCHEDULE-STATUS",
- )
+ def duplicateAndNormalize(calendar):
+ calendar = calendar.duplicate()
+ calendar.removeAlarms()
+ calendar.filterProperties(remove=("X-CALENDARSERVER-ACCESS",), do_subcomponents=False)
+ calendar.filterProperties(remove=(
+ "CREATED",
+ "DTSTAMP",
+ "LAST-MODIFIED",
+ ))
+ calendar.removeXProperties()
+ calendar.removePropertyParameters("ATTENDEE", ("SCHEDULE-AGENT", "SCHEDULE-STATUS",))
+ calendar.removePropertyParametersByValue("ATTENDEE", (("PARTSTAT", "NEEDS-ACTION"),))
+ return calendar
+
+ # Normalize components for comparison
+ self.calendar1 = duplicateAndNormalize(self.calendar1)
+ self.calendar2 = duplicateAndNormalize(self.calendar2)
- removeAttendeeParametersByValue = (
- ("PARTSTAT", "NEEDS-ACTION"),
- )
-
- # Do straight comparison without alarms
- self.calendar1 = self.calendar1.duplicate()
- self.calendar1.removeAlarms()
- self.calendar1.filterProperties(remove=removeProperties)
- self.calendar1.removeXProperties()
- self.calendar1.removePropertyParameters("ATTENDEE", removeAttendeeParameters)
- self.calendar1.removePropertyParametersByValue("ATTENDEE", removeAttendeeParametersByValue)
- self.calendar2 = self.calendar2.duplicate()
- self.calendar2.removeAlarms()
- self.calendar2.filterProperties(remove=removeProperties)
- self.calendar2.removeXProperties()
- self.calendar2.removePropertyParameters("ATTENDEE", removeAttendeeParameters)
- self.calendar2.removePropertyParametersByValue("ATTENDEE", removeAttendeeParametersByValue)
-
return self.calendar1 == self.calendar2
def attendeeMerge(self, attendee):
@@ -92,18 +81,18 @@
self.attendee = attendee
+ def duplicateAndNormalize(calendar):
+ calendar = calendar.duplicate()
+ calendar.normalizePropertyValueLists("EXDATE")
+ calendar.removeXProperties(("X-CALENDARSERVER-PRIVATE-COMMENT",))
+ iTipGenerator.prepareSchedulingMessage(calendar)
+ return calendar
+
# Do straight comparison without alarms
- self.calendar1 = self.calendar1.duplicate()
+ self.calendar1 = duplicateAndNormalize(self.calendar1)
self.calendar1.attendeesView((attendee,))
- self.calendar1.normalizePropertyValueLists("EXDATE")
- self.calendar1.removeXProperties(("X-CALENDARSERVER-PRIVATE-COMMENT",))
- iTipGenerator.prepareSchedulingMessage(self.calendar1)
+ self.calendar2 = duplicateAndNormalize(self.calendar2)
- self.calendar2 = self.calendar2.duplicate()
- self.calendar2.normalizePropertyValueLists("EXDATE")
- self.calendar2.removeXProperties(("X-CALENDARSERVER-PRIVATE-COMMENT",))
- iTipGenerator.prepareSchedulingMessage(self.calendar2)
-
if self.calendar1 == self.calendar2:
return True, True
Modified: CalendarServer/trunk/twistedcaldav/scheduling/itip.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/itip.py 2008-09-26 04:23:13 UTC (rev 3065)
+++ CalendarServer/trunk/twistedcaldav/scheduling/itip.py 2008-09-26 16:19:13 UTC (rev 3066)
@@ -407,10 +407,7 @@
continue
attendee = component.getAttendeeProperty((recipient,))
if attendee:
- if "PARTSTAT" in attendee.params():
- partstat = attendee.params()["PARTSTAT"][0]
- else:
- partstat = "NEEDS-ACTION"
+ partstat = attendee.params().get("PARTSTAT", ("NEEDS-ACTION",))[0]
if partstat == "NEEDS-ACTION":
component.addProperty(Property("X-APPLE-NEEDS-REPLY", "TRUE"))
@@ -544,13 +541,14 @@
attendeeProps = itip.getAttendeeProperties((attendee,))
assert attendeeProps, "Must have some matching ATTENDEEs"
for attendeeProp in attendeeProps:
- if "PARTSTAT" in attendeeProp.params():
- attendeeProp.params()["PARTSTAT"][0] = "DECLINED"
- else:
- attendeeProp.params()["PARTSTAT"] = ["DECLINED"]
+ attendeeProp.params().setdefault("PARTSTAT", ["DECLINED",])[0] = "DECLINED"
# Add REQUEST-STATUS to each top-level component
- itip.addPropertyToAllComponents(Property("REQUEST-STATUS", "2.0;Success"))
+ itip.addPropertyToAllComponents(Property("REQUEST-STATUS", ["2.0", "Success",]))
+
+ # Strip out unwanted bits
+ iTipGenerator.prepareSchedulingMessage(itip)
+
return itip
@staticmethod
@@ -559,43 +557,15 @@
Remove properties and parameters that should not be sent in an iTIP message
"""
- # Component properties
- def stripSubComponents(component, strip):
-
- for subcomponent in tuple(component.subcomponents()):
- if subcomponent.name() in strip:
- component.removeComponent(subcomponent)
+ # Alarms
+ itip.removeAlarms()
- # Component properties
- def stripComponentProperties(component, properties):
-
- for property in tuple(component.properties()):
- if property.name() in properties:
- component.removeProperty(property)
-
- # Property parameters
- def stripPropertyParameters(properties, parameters):
-
- for property in properties:
- for parameter in parameters:
- try:
- del property.params()[parameter]
- except KeyError:
- pass
-
# Top-level properties
- stripComponentProperties(itip, ("X-CALENDARSERVER-ACCESS",))
+ itip.filterProperties(remove=("X-CALENDARSERVER-ACCESS",), do_subcomponents=False)
# Component properties
- for component in itip.subcomponents():
- stripSubComponents(component, ("VALARM",))
- stripComponentProperties(component, (
- "X-CALENDARSERVER-ATTENDEE-COMMENT",
- ))
- stripPropertyParameters(component.properties("ATTENDEE"), (
- "SCHEDULE-AGENT",
- "SCHEDULE-STATUS",
- ))
- stripPropertyParameters(component.properties("ORGANIZER"), (
- "SCHEDULE-STATUS",
- ))
+ itip.filterProperties(remove=("X-CALENDARSERVER-ATTENDEE-COMMENT",))
+
+ # Property Parameters
+ itip.removePropertyParameters("ATTENDEE", ("SCHEDULE-AGENT", "SCHEDULE-STATUS",))
+ itip.removePropertyParameters("ORGANIZER", ("SCHEDULE-STATUS",))
Modified: CalendarServer/trunk/twistedcaldav/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/processing.py 2008-09-26 04:23:13 UTC (rev 3065)
+++ CalendarServer/trunk/twistedcaldav/scheduling/processing.py 2008-09-26 16:19:13 UTC (rev 3066)
@@ -392,7 +392,8 @@
destinationcal = True,
calendar = calendar,
isiTIP = False,
- allowImplicitSchedule = False
+ allowImplicitSchedule = False,
+ internal_request = True,
).run()
returnValue(newchild)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080926/9eb489e2/attachment-0001.html
More information about the calendarserver-changes
mailing list