[CalendarServer-changes] [6790] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jan 19 16:46:38 PST 2011
Revision: 6790
http://trac.macosforge.org/projects/calendarserver/changeset/6790
Author: sagen at apple.com
Date: 2011-01-19 16:46:25 -0800 (Wed, 19 Jan 2011)
Log Message:
-----------
When fixing DTSTART/UNTIL type mismatches, let vobject do it.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/ical.py
CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py 2011-01-19 21:12:56 UTC (rev 6789)
+++ CalendarServer/trunk/twistedcaldav/ical.py 2011-01-20 00:46:25 UTC (rev 6790)
@@ -1377,30 +1377,26 @@
subcomponent.hasProperty("RRULE")):
dtValue = subcomponent.propertyNativeValue("DTSTART")
dtType = type(dtValue)
+ # Using properties("RRULE") rather than getRRuleSet() here
+ # because the dateutil rrule's _until values are datetime
+ # even if the UNTIL is a date (and therefore we can't
+ # check validity without doing the following):
for rrule in subcomponent.properties("RRULE"):
indexedTokens = {}
indexedTokens.update([valuePart.split("=")
for valuePart in rrule.value().split(";")])
until = indexedTokens.get("UNTIL", None)
- # FIXME: can "until" ever be anything but a unicode?
if until:
untilType = datetime.date if len(until) == 8 else datetime.datetime
if untilType is not dtType:
msg = "Calendar resources must have matching type for DTSTART and UNTIL"
log.debug(msg)
if fix:
- log.debug("Fixing mismatch")
- if dtType is datetime.datetime:
- # TODO: does this need to be smarter?
- indexedTokens["UNTIL"] = "%sT000000" % (until,)
- else:
- # TODO: does this need to be smarter?
- # It's just stripping off the time.
- indexedTokens["UNTIL"] = until[:8]
-
- # Update rrule
- newValue = u";".join(["%s=%s" % (k,v) for k,v in indexedTokens.iteritems()])
- rrule.setValue(newValue)
+ rrules = subcomponent.getRRuleSet()
+ if rrules:
+ log.debug("Fixing mismatch")
+ # vobject fixes DTSTART/UNTIL mismatches
+ subcomponent.setRRuleSet(rrules)
else:
raise InvalidICalendarDataError(msg)
Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py 2011-01-19 21:12:56 UTC (rev 6789)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py 2011-01-20 00:46:25 UTC (rev 6790)
@@ -124,6 +124,8 @@
# Fix it
calendar.validateComponentsForCalDAV(False, fix=True)
+ self.assertTrue("RRULE:FREQ=DAILY;UNTIL=20110121T203000Z\r\n"
+ in str(calendar))
# Now it should pass without fixing
calendar.validateComponentsForCalDAV(False, fix=False)
@@ -167,6 +169,7 @@
# Fix it
calendar.validateComponentsForCalDAV(False, fix=True)
+ self.assertTrue("RRULE:FREQ=DAILY;UNTIL=20110131\r\n" in str(calendar))
# Now it should pass without fixing
calendar.validateComponentsForCalDAV(False, fix=False)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110119/39d54b43/attachment.html>
More information about the calendarserver-changes
mailing list