[CalendarServer-changes] [1010]
CalendarServer/branches/users/cdaboo/availability-1005
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jan 10 12:02:35 PST 2007
Revision: 1010
http://trac.macosforge.org/projects/calendarserver/changeset/1010
Author: cdaboo at apple.com
Date: 2007-01-10 12:02:34 -0800 (Wed, 10 Jan 2007)
Log Message:
-----------
Index VAVAILABILITY components via instance expansion. Also, add support for VAVAILABILITY in new vObject branch, and
switch to using that.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/availability-1005/run
CalendarServer/branches/users/cdaboo/availability-1005/twistedcaldav/instance.py
Removed Paths:
-------------
CalendarServer/branches/users/cdaboo/availability-1005/lib-patches/vobject/README.patch
CalendarServer/branches/users/cdaboo/availability-1005/lib-patches/vobject/src.vobject.base.patch
CalendarServer/branches/users/cdaboo/availability-1005/lib-patches/vobject/tests.tests.patch
Deleted: CalendarServer/branches/users/cdaboo/availability-1005/lib-patches/vobject/README.patch
===================================================================
--- CalendarServer/branches/users/cdaboo/availability-1005/lib-patches/vobject/README.patch 2007-01-10 17:13:19 UTC (rev 1009)
+++ CalendarServer/branches/users/cdaboo/availability-1005/lib-patches/vobject/README.patch 2007-01-10 20:02:34 UTC (rev 1010)
@@ -1,13 +0,0 @@
-Index: README.txt
-===================================================================
---- README.txt (revision 164)
-+++ README.txt (working copy)
-@@ -193,7 +193,7 @@
- serializing will add any required computable attributes (like 'VERSION')
-
- >>> j.serialize()
--u'BEGIN:VCARD\r\nVERSION:3.0\r\nEMAIL;TYPE=INTERNET:jeffrey at osafoundation.org\r\nFN:Jeffrey Harris\r\nN:Harris;Jeffrey;;;\r\nEND:VCARD\r\n'
-+'BEGIN:VCARD\r\nVERSION:3.0\r\nEMAIL;TYPE=INTERNET:jeffrey at osafoundation.org\r\nFN:Jeffrey Harris\r\nN:Harris;Jeffrey;;;\r\nEND:VCARD\r\n'
- >>> j.prettyPrint()
- VCARD
- VERSION: 3.0
Deleted: CalendarServer/branches/users/cdaboo/availability-1005/lib-patches/vobject/src.vobject.base.patch
===================================================================
--- CalendarServer/branches/users/cdaboo/availability-1005/lib-patches/vobject/src.vobject.base.patch 2007-01-10 17:13:19 UTC (rev 1009)
+++ CalendarServer/branches/users/cdaboo/availability-1005/lib-patches/vobject/src.vobject.base.patch 2007-01-10 20:02:34 UTC (rev 1010)
@@ -1,96 +0,0 @@
-Index: src/vobject/base.py
-===================================================================
---- src/vobject/base.py (revision 164)
-+++ src/vobject/base.py (working copy)
-@@ -842,14 +842,36 @@
- return param
-
- def foldOneLine(outbuf, input, lineLength = 75):
-- if isinstance(input, basestring): input = StringIO.StringIO(input)
-- input.seek(0)
-- outbuf.write(input.read(lineLength) + CRLF)
-- brokenline = input.read(lineLength - 1)
-- while brokenline:
-- outbuf.write(' ' + brokenline + CRLF)
-- brokenline = input.read(lineLength - 1)
-+ # Folding line procedure that ensures multi-byte utf-8 sequences are not broken
-+ # across lines
-
-+ if len(input) < lineLength:
-+ # Optimize for unfolded line case
-+ outbuf.write(input)
-+ else:
-+ # Look for valid utf8 range and write that out
-+ start = 0
-+ written = 0
-+ while written < len(input):
-+ # Start max length -1 chars on from where we are
-+ offset = start + lineLength - 1
-+ if offset >= len(input):
-+ line = input[start:]
-+ outbuf.write(line)
-+ written = len(input)
-+ else:
-+ # Check whether next char is valid utf8 lead byte
-+ while (input[offset] > 0x7F) and ((ord(input[offset]) & 0xC0) == 0x80):
-+ # Step back until we have a valid char
-+ offset -= 1
-+
-+ line = input[start:offset]
-+ outbuf.write(line)
-+ outbuf.write("\r\n ")
-+ written += offset - start
-+ start = offset
-+ outbuf.write("\r\n")
-+
- def defaultSerialize(obj, buf, lineLength):
- """Encode and fold obj and its children, write to buf or return a string."""
-
-@@ -861,12 +883,12 @@
- else:
- groupString = obj.group + '.'
- if obj.useBegin:
-- foldOneLine(outbuf, groupString + u"BEGIN:" + obj.name, lineLength)
-+ foldOneLine(outbuf, str(groupString + u"BEGIN:" + obj.name), lineLength)
- for child in obj.getSortedChildren():
- #validate is recursive, we only need to validate once
- child.serialize(outbuf, lineLength, validate=False)
- if obj.useBegin:
-- foldOneLine(outbuf, groupString + u"END:" + obj.name, lineLength)
-+ foldOneLine(outbuf, str(groupString + u"END:" + obj.name), lineLength)
- if DEBUG: logger.debug("Finished %s" % obj.name.upper())
-
- elif isinstance(obj, ContentLine):
-@@ -875,14 +897,18 @@
- if obj.behavior and not startedEncoded: obj.behavior.encode(obj)
- s=StringIO.StringIO() #unfolded buffer
- if obj.group is not None:
-- s.write(obj.group + '.')
-+ s.write(str(obj.group + '.'))
- if DEBUG: logger.debug("Serializing line" + str(obj))
-- s.write(obj.name.upper())
-+ s.write(str(obj.name.upper()))
- for key, paramvals in obj.params.iteritems():
-- s.write(';' + key + '=' + ','.join(map(dquoteEscape, paramvals)))
-- s.write(':' + obj.value)
-+ s.write(';' + str(key) + '=' + ','.join(map(dquoteEscape, paramvals)).encode("utf-8"))
-+ if isinstance(obj.value, unicode):
-+ strout = obj.value.encode("utf-8")
-+ else:
-+ strout = obj.value
-+ s.write(':' + strout)
- if obj.behavior and not startedEncoded: obj.behavior.decode(obj)
-- foldOneLine(outbuf, s, lineLength)
-+ foldOneLine(outbuf, s.getvalue(), lineLength)
- if DEBUG: logger.debug("Finished %s line" % obj.name.upper())
-
- return buf or outbuf.getvalue()
-@@ -1023,7 +1049,7 @@
- else:
- obj = ContentLine(name, [], '')
- obj.behavior = behavior
-- obj.isNative = True
-+ obj.isNative = False
- return obj
-
-
Deleted: CalendarServer/branches/users/cdaboo/availability-1005/lib-patches/vobject/tests.tests.patch
===================================================================
--- CalendarServer/branches/users/cdaboo/availability-1005/lib-patches/vobject/tests.tests.patch 2007-01-10 17:13:19 UTC (rev 1009)
+++ CalendarServer/branches/users/cdaboo/availability-1005/lib-patches/vobject/tests.tests.patch 2007-01-10 20:02:34 UTC (rev 1010)
@@ -1,51 +0,0 @@
-Index: tests/tests.py
-===================================================================
---- tests/tests.py (revision 164)
-+++ tests/tests.py (working copy)
-@@ -280,7 +280,7 @@
- >>> silly.stuff
- <STUFF{}foldedline>
- >>> original = silly.serialize()
-- >>> f3 = StringIO.StringIO(original)
-+ >>> f3 = StringIO.StringIO(original.decode("utf-8"))
- >>> silly2 = base.readOne(f3)
- >>> silly2.serialize()==original
- True
-@@ -289,7 +289,7 @@
- >>> ex1
- <*unnamed*| [<CN{}Babs Jensen>, <CN{}Barbara J Jensen>, <EMAIL{}babs at umich.edu>, <PHONE{}+1 313 747-4454>, <SN{}Jensen>, <X-ID{}1234567890>]>
- >>> ex1.serialize()
-- u'CN:Babs Jensen\r\nCN:Barbara J Jensen\r\nEMAIL:babs at umich.edu\r\nPHONE:+1 313 747-4454\r\nSN:Jensen\r\nX-ID:1234567890\r\n'
-+ 'CN:Babs Jensen\r\nCN:Barbara J Jensen\r\nEMAIL:babs at umich.edu\r\nPHONE:+1 313 747-4454\r\nSN:Jensen\r\nX-ID:1234567890\r\n'
- """,
-
- "Import icaltest" :
-@@ -306,7 +306,7 @@
- >>> c.vevent.valarm.description.value
- u'Event reminder, with comma\nand line feed'
- >>> c.vevent.valarm.description.serialize()
-- u'DESCRIPTION:Event reminder\\, with comma\\nand line feed\r\n'
-+ 'DESCRIPTION:Event reminder\\, with comma\\nand line feed\r\n'
- >>> vevent = c.vevent.transformFromNative()
- >>> vevent.rrule
- <RRULE{}FREQ=Weekly;COUNT=10>
-@@ -352,6 +352,7 @@
- >>> vevent.summary.value
- u'The title \u3053\u3093\u306b\u3061\u306f\u30ad\u30c6\u30a3'
- >>> summary = vevent.summary.value
-+ >>> test = str(vevent.serialize()),
- """,
-
- # make sure date valued UNTILs in rrules are in a reasonable timezone,
-@@ -690,9 +691,9 @@
- u'home'
- >>> card.group = card.tel.group = 'new'
- >>> card.tel.serialize().strip()
-- u'new.TEL;TYPE=fax,voice,msg:+49 3581 123456'
-+ 'new.TEL;TYPE=fax,voice,msg:+49 3581 123456'
- >>> card.serialize().splitlines()[0]
-- u'new.BEGIN:VCARD'
-+ 'new.BEGIN:VCARD'
- >>> dtstart = base.newFromBehavior('dtstart')
- >>> dtstart.group = "badgroup"
- >>> dtstart.serialize()
Modified: CalendarServer/branches/users/cdaboo/availability-1005/run
===================================================================
--- CalendarServer/branches/users/cdaboo/availability-1005/run 2007-01-10 17:13:19 UTC (rev 1009)
+++ CalendarServer/branches/users/cdaboo/availability-1005/run 2007-01-10 20:02:34 UTC (rev 1010)
@@ -503,8 +503,8 @@
base="http://svn.osafoundation.org";
;;
esac;
-svn_uri="${base}/vobject/trunk";
-svn_get "vObject" "${vobject}" "${svn_uri}" 164;
+svn_uri="${base}/vobject/branches/users/cdaboo/vavailability-173";
+svn_get "vObject" "${vobject}" "${svn_uri}" 177;
if ! "${disable_setup}"; then
# Avoid having to download setuptools to build vobject
Modified: CalendarServer/branches/users/cdaboo/availability-1005/twistedcaldav/instance.py
===================================================================
--- CalendarServer/branches/users/cdaboo/availability-1005/twistedcaldav/instance.py 2007-01-10 17:13:19 UTC (rev 1009)
+++ CalendarServer/branches/users/cdaboo/availability-1005/twistedcaldav/instance.py 2007-01-10 20:02:34 UTC (rev 1010)
@@ -21,8 +21,11 @@
"""
import datetime
+
from twistedcaldav.dateops import normalizeForIndex, compareDateTime, differenceDateTime, periodEnd
+from vobject.icalendar import utc
+
# The maximum number of instances we will ezpand out to.
# Raise a TooManyInstancesError exception if we exceed this.
max_allowed_instances = 1000
@@ -113,7 +116,7 @@
@param limit: datetime.date value representing the end of the expansion.
"""
- # Look at each VEVENT, VTODO, VJOURNAL
+ # Look at each component type
overrides = []
for component in componentSet:
if component.name() == "VEVENT":
@@ -131,6 +134,8 @@
raise NotImplementedError("VJOURNAL recurrence expansion not supported yet")
elif component.name() == "VFREEBUSY":
self._addFreeBusyComponent(component, limit)
+ elif component.name() == "VAVAILABILITY":
+ self._addAvailabilityComponent(component, limit)
for component in overrides:
if component.name() == "VEVENT":
@@ -347,4 +352,29 @@
start = normalizeForIndex(period[0])
end = normalizeForIndex(periodEnd(period))
self.addInstance(Instance(component, start, end))
-
+
+ def _addAvailabilityComponent(self, component, limit):
+ """
+ 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
+ optional DTSTART and DTEND/DURATION defining a single time-range which may be bounded
+ depedning on the presence of the properties. If unbounded at one or both ends, we will
+ set the time to 1/1/1900 in the past and 1/1/3000 in the future.
+ @param component: the Component to expand
+ @param limit: the end datetime.datetime for expansion
+ """
+
+ start = component.getStartDateUTC()
+ if start is not None and (compareDateTime(start, limit) >= 0):
+ # If the free busy is beyond the end of the range we want, ignore it
+ return
+ if start is None:
+ start = datetime.datetime(1900, 1, 1, 0, 0, 0, tzinfo=utc)
+ start = normalizeForIndex(start)
+
+ end = component.getEndDateUTC()
+ if end is None:
+ end = datetime.datetime(3000, 1, 1, 0, 0, 0, tzinfo=utc)
+ end = normalizeForIndex(end)
+
+ self.addInstance(Instance(component, start, end))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070110/457442d7/attachment.html
More information about the calendarserver-changes
mailing list