[CalendarServer-changes] [10744] CalendarServer/trunk/twistedcaldav/instance.py
source_changes at macosforge.org
source_changes at macosforge.org
Fri Feb 15 14:01:47 PST 2013
Revision: 10744
http://trac.calendarserver.org//changeset/10744
Author: cdaboo at apple.com
Date: 2013-02-15 14:01:47 -0800 (Fri, 15 Feb 2013)
Log Message:
-----------
Fix boundary case on an expand report with an all-day event.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/instance.py
Modified: CalendarServer/trunk/twistedcaldav/instance.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/instance.py 2013-02-15 21:57:55 UTC (rev 10743)
+++ CalendarServer/trunk/twistedcaldav/instance.py 2013-02-15 22:01:47 UTC (rev 10744)
@@ -104,7 +104,10 @@
self.ignoreInvalidInstances = ignoreInvalidInstances
self.normalizeFunction = normalizeFunction
+ self.adjustedLowerLimit = None
+ self.adjustedUpperLimit = None
+
def __iter__(self):
# Return keys in sorted order via iterator
for i in sorted(self.instances.keys()):
@@ -184,6 +187,28 @@
raise TooManyInstancesError()
+ def _setupLimits(self, dt, lowerLimit, upperLimit):
+ """
+ Change the limits to account for testing against DATE only values. The lower limit
+ is simply truncated to its date value. The upper limit is truncated to one day past
+ the date value.
+ """
+
+ if self.adjustedUpperLimit is None:
+ if dt.isDateOnly():
+ if lowerLimit:
+ self.adjustedLowerLimit = lowerLimit.duplicate()
+ self.adjustedLowerLimit.setDateOnly(True)
+ self.adjustedUpperLimit = upperLimit.duplicate()
+ self.adjustedUpperLimit.setDateOnly(True)
+ self.adjustedUpperLimit.offsetDay(1)
+ else:
+ self.adjustedLowerLimit = lowerLimit
+ self.adjustedUpperLimit = upperLimit
+
+ return (self.adjustedLowerLimit, self.adjustedUpperLimit,)
+
+
def _getMasterEventDetails(self, component):
"""
Logic here comes from RFC4791 Section 9.9
@@ -210,7 +235,7 @@
return (rulestart, start, end, duration,)
- def _addMasterEventComponent(self, component, lowerLimit, upperlimit):
+ def _addMasterEventComponent(self, component, lowerLimit, upperLimit):
"""
Add the specified master VEVENT Component to the instance list, expanding it
within the supplied time range.
@@ -223,10 +248,11 @@
return
rulestart, start, end, duration = details
- self._addMasterComponent(component, lowerLimit, upperlimit, rulestart, start, end, duration)
+ lowerLimit, upperLimit = self._setupLimits(start, lowerLimit, upperLimit)
+ self._addMasterComponent(component, lowerLimit, upperLimit, rulestart, start, end, duration)
- def _addOverrideEventComponent(self, component, lowerLimit, upperlimit, got_master):
+ def _addOverrideEventComponent(self, component, lowerLimit, upperLimit, got_master):
"""
Add the specified overridden VEVENT Component to the instance list, replacing
the one generated by the master component.
@@ -241,7 +267,8 @@
return
_ignore_rulestart, start, end, _ignore_duration = details
- self._addOverrideComponent(component, lowerLimit, upperlimit, start, end, got_master)
+ lowerLimit, upperLimit = self._setupLimits(start, lowerLimit, upperLimit)
+ self._addOverrideComponent(component, lowerLimit, upperLimit, start, end, got_master)
def _getMasterToDoDetails(self, component):
@@ -290,7 +317,7 @@
return (rulestart, start, end, duration,)
- def _addMasterToDoComponent(self, component, lowerLimit, upperlimit):
+ def _addMasterToDoComponent(self, component, lowerLimit, upperLimit):
"""
Add the specified master VTODO Component to the instance list, expanding it
within the supplied time range.
@@ -302,10 +329,11 @@
return
rulestart, start, end, duration = details
- self._addMasterComponent(component, lowerLimit, upperlimit, rulestart, start, end, duration)
+ lowerLimit, upperLimit = self._setupLimits(start, lowerLimit, upperLimit)
+ self._addMasterComponent(component, lowerLimit, upperLimit, rulestart, start, end, duration)
- def _addOverrideToDoComponent(self, component, lowerLimit, upperlimit, got_master):
+ def _addOverrideToDoComponent(self, component, lowerLimit, upperLimit, got_master):
"""
Add the specified overridden VTODO Component to the instance list, replacing
the one generated by the master component.
@@ -320,7 +348,8 @@
return
_ignore_rulestart, start, end, _ignore_duration = details
- self._addOverrideComponent(component, lowerLimit, upperlimit, start, end, got_master)
+ lowerLimit, upperLimit = self._setupLimits(start, lowerLimit, upperLimit)
+ self._addOverrideComponent(component, lowerLimit, upperLimit, start, end, got_master)
def _addMasterComponent(self, component, lowerLimit, upperlimit, rulestart, start, end, duration):
@@ -422,7 +451,7 @@
self.addInstance(Instance(component, start, end, originalStart, False, False))
- def _addFreeBusyComponent(self, component, lowerLimit, upperlimit):
+ def _addFreeBusyComponent(self, component, lowerLimit, upperLimit):
"""
Add the specified master VFREEBUSY Component to the instance list, expanding it
within the supplied time range.
@@ -435,8 +464,11 @@
if end is None and start is not None:
raise ValueError("VFREEBUSY component must have both DTSTART and DTEND: %r" % (component,))
+ if start:
+ lowerLimit, upperLimit = self._setupLimits(start, lowerLimit, upperLimit)
+
# If the free busy is beyond the end of the range we want, ignore it
- if start is not None and start >= upperlimit:
+ if start is not None and start >= upperLimit:
return
# If the free busy is before the start of the range we want, ignore it
@@ -450,14 +482,14 @@
for period in fb.value():
# Ignore if period starts after limit
period = period.getValue()
- if period.getStart() >= upperlimit:
+ if period.getStart() >= upperLimit:
continue
start = self.normalizeFunction(period.getStart())
end = self.normalizeFunction(period.getEnd())
self.addInstance(Instance(component, start, end))
- def _addAvailabilityComponent(self, component, lowerLimit, upperlimit):
+ def _addAvailabilityComponent(self, component, lowerLimit, upperLimit):
"""
Add the specified master VAVAILABILITY Component to the instance list, expanding it
within the supplied time range. VAVAILABILITY components are not recurring, they have an
@@ -469,7 +501,11 @@
"""
start = component.getStartDateUTC()
- if start is not None and start >= upperlimit:
+
+ if start:
+ lowerLimit, upperLimit = self._setupLimits(start, lowerLimit, upperLimit)
+
+ if start is not None and start >= upperLimit:
# If the availability is beyond the end of the range we want, ignore it
return
if start is None:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130215/684c726f/attachment.html>
More information about the calendarserver-changes
mailing list