[CalendarServer-changes] [7650] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jun 23 09:11:19 PDT 2011
Revision: 7650
http://trac.macosforge.org/projects/calendarserver/changeset/7650
Author: cdaboo at apple.com
Date: 2011-06-23 09:11:19 -0700 (Thu, 23 Jun 2011)
Log Message:
-----------
Remove store apis that return iCalendar/vCard data as text. Instead require that V* object is returned and then it is up to
the caller to serialize that when needed.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tools/warmup.py
CalendarServer/trunk/twistedcaldav/resource.py
CalendarServer/trunk/twistedcaldav/storebridge.py
CalendarServer/trunk/twistedcaldav/upgrade.py
CalendarServer/trunk/txdav/caldav/datastore/file.py
CalendarServer/trunk/txdav/caldav/datastore/scheduling.py
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/caldav/datastore/test/common.py
CalendarServer/trunk/txdav/caldav/icalendarstore.py
CalendarServer/trunk/txdav/carddav/datastore/file.py
CalendarServer/trunk/txdav/carddav/datastore/sql.py
CalendarServer/trunk/txdav/carddav/datastore/test/common.py
CalendarServer/trunk/txdav/carddav/iaddressbookstore.py
CalendarServer/trunk/txdav/common/datastore/file.py
CalendarServer/trunk/txdav/common/datastore/sql.py
Modified: CalendarServer/trunk/calendarserver/tools/warmup.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/warmup.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/calendarserver/tools/warmup.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -1,7 +1,7 @@
#!/usr/bin/env python
##
-# Copyright (c) 2006-2009 Apple Inc. All rights reserved.
+# Copyright (c) 2006-2011 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -168,7 +168,7 @@
child = calendarCollection.getChild(name)
#sys.stdout.write("+")
- child.iCalendarText()
+ child._text()
readProperties(child)
Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/twistedcaldav/resource.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -1522,15 +1522,15 @@
@inlineCallbacks
- def iCalendarTextFiltered(self, isowner, accessUID=None):
+ def iCalendarFiltered(self, isowner, accessUID=None):
# Now "filter" the resource calendar data
caldata = PrivateEventFilter(self.accessMode, isowner).filter(
- (yield self.iCalendarText())
+ (yield self.iCalendar())
)
if accessUID:
caldata = PerUserDataFilter(accessUID).filter(caldata)
- returnValue(str(caldata))
+ returnValue(caldata)
def iCalendarText(self):
Modified: CalendarServer/trunk/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/storebridge.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -962,9 +962,8 @@
continue
# Get the access filtered view of the data
- caldata = yield child.iCalendarTextFiltered(isowner, accessPrincipal.principalUID() if accessPrincipal else "")
try:
- subcalendar = VCalendar.fromString(caldata)
+ subcalendar = yield child.iCalendarFiltered(isowner, accessPrincipal.principalUID() if accessPrincipal else "")
except ValueError:
continue
assert subcalendar.name() == "VCALENDAR"
@@ -1631,9 +1630,6 @@
return succeed(self._newStoreObject.size())
- def text(self):
- return self._newStoreObject.text()
-
def component(self):
return self._newStoreObject.component()
@@ -1643,9 +1639,9 @@
log.debug("Resource not found: %s" % (self,))
raise HTTPError(responsecode.NOT_FOUND)
- output = yield self.text()
+ output = yield self.component()
- response = Response(200, {}, output)
+ response = Response(200, {}, str(output))
response.headers.setHeader("content-type", self.contentType())
returnValue(response)
@@ -1800,7 +1796,11 @@
returnValue(txn)
- iCalendarText = _CommonObjectResource.text
+ @inlineCallbacks
+ def iCalendarText(self):
+ data = yield self.iCalendar()
+ returnValue(str(data))
+
iCalendar = _CommonObjectResource.component
@@ -2054,9 +2054,14 @@
_componentFromStream = VCard.fromString
- vCardText = _CommonObjectResource.text
+ @inlineCallbacks
+ def vCardText(self):
+ data = yield self.vCard()
+ returnValue(str(data))
+ vCard = _CommonObjectResource.component
+
class _NotificationChildHelper(object):
"""
Methods for things which are like notification objects.
Modified: CalendarServer/trunk/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/upgrade.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -928,8 +928,7 @@
owner = LocalCalendarUser(cua, ownerPrincipal,
inbox, ownerPrincipal.scheduleInboxURL())
- data = yield inboxItem.iCalendarText()
- calendar = Component.fromString(data)
+ calendar = yield inboxItem.iCalendar()
try:
method = calendar.propertyValue("METHOD")
except ValueError:
Modified: CalendarServer/trunk/txdav/caldav/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/file.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/txdav/caldav/datastore/file.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -342,7 +342,7 @@
def component(self):
- text = self.text()
+ text = self._text()
try:
component = VComponent.fromString(text)
@@ -356,7 +356,7 @@
return component
- def text(self):
+ def _text(self):
if self._component is not None:
return str(self._component)
try:
@@ -390,8 +390,6 @@
)
return text
- iCalendarText = text
-
def uid(self):
if not hasattr(self, "_uid"):
self._uid = self.component().resourceUID()
Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -1,6 +1,6 @@
# -*- test-case-name: txdav.caldav.datastore.test.test_scheduling -*-
##
-# Copyright (c) 2010 Apple Inc. All rights reserved.
+# Copyright (c) 2010-2011 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -119,7 +119,6 @@
implements(ICalendarObject)
def setComponent(self, component): ""
def component(self): ""
- def iCalendarText(self): ""
def uid(self): ""
def componentType(self): ""
def organizer(self): ""
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -614,12 +614,9 @@
@inlineCallbacks
def component(self):
- returnValue(VComponent.fromString((yield self.iCalendarText())))
+ returnValue(VComponent.fromString((yield self._text())))
- iCalendarText = CommonObjectResource.text
-
-
@inlineCallbacks
def organizer(self):
returnValue((yield self.component()).getOrganizer())
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/common.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/common.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -1,6 +1,6 @@
# -*- test-case-name: txdav.caldav.datastore -*-
##
-# Copyright (c) 2010 Apple Inc. All rights reserved.
+# Copyright (c) 2010-2011 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -1020,7 +1020,7 @@
L{ICalendarObject.iCalendarText} returns a C{str} describing the same
data provided by L{ICalendarObject.component}.
"""
- text = yield (yield self.calendarObjectUnderTest()).iCalendarText()
+ text = yield (yield self.calendarObjectUnderTest())._text()
self.assertIsInstance(text, str)
self.failUnless(text.startswith("BEGIN:VCALENDAR\r\n"))
self.assertIn("\r\nUID:uid1\r\n", text)
@@ -1349,7 +1349,7 @@
(yield self.calendarObjectUnderTest()).properties()[propertyName],
propertyContent)
obj = yield self.calendarObjectUnderTest()
- event1_text = yield obj.iCalendarText()
+ event1_text = yield obj._text()
event1_text_withDifferentSubject = event1_text.replace(
"SUMMARY:CalDAV protocol updates",
"SUMMARY:Changed"
Modified: CalendarServer/trunk/txdav/caldav/icalendarstore.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/icalendarstore.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/txdav/caldav/icalendarstore.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -1,6 +1,6 @@
# -*- test-case-name: txdav.caldav.datastore -*-
##
-# Copyright (c) 2010 Apple Inc. All rights reserved.
+# Copyright (c) 2010-2011 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -367,14 +367,6 @@
@return: a C{VCALENDAR} L{VComponent}.
"""
- def iCalendarText():
- """
- Retrieve the iCalendar text data for this calendar object.
-
- @return: a string containing iCalendar data for a single
- calendar object.
- """
-
def uid():
"""
Retrieve the UID for this calendar object.
Modified: CalendarServer/trunk/txdav/carddav/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/file.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/txdav/carddav/datastore/file.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -223,7 +223,7 @@
def component(self):
if self._component is not None:
return self._component
- text = self.text()
+ text = self._text()
try:
component = VComponent.fromString(text)
@@ -235,7 +235,7 @@
return component
- def text(self):
+ def _text(self):
if self._component is not None:
return str(self._component)
try:
@@ -261,8 +261,6 @@
)
return text
- vCardText = text
-
def uid(self):
if not hasattr(self, "_uid"):
self._uid = self.component().resourceUID()
Modified: CalendarServer/trunk/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/sql.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/txdav/carddav/datastore/sql.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -271,12 +271,9 @@
@inlineCallbacks
def component(self):
- returnValue(VCard.fromString((yield self.vCardText())))
+ returnValue(VCard.fromString((yield self._text())))
- vCardText = CommonObjectResource.text
-
-
# IDataStoreObject
def contentType(self):
"""
Modified: CalendarServer/trunk/txdav/carddav/datastore/test/common.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/test/common.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/txdav/carddav/datastore/test/common.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -594,7 +594,7 @@
L{IAddressBookObject.iAddressBookText} returns a C{str} describing the same
data provided by L{IAddressBookObject.component}.
"""
- text = yield (yield self.addressbookObjectUnderTest()).vCardText()
+ text = yield (yield self.addressbookObjectUnderTest())._text()
self.assertIsInstance(text, str)
self.failUnless(text.startswith("BEGIN:VCARD\r\n"))
self.assertIn("\r\nUID:uid1\r\n", text)
@@ -906,7 +906,7 @@
],
propertyContent)
obj = yield self.addressbookObjectUnderTest()
- vcard1_text = yield obj.vCardText()
+ vcard1_text = yield obj._text()
vcard1_text_withDifferentNote = vcard1_text.replace(
"NOTE:CardDAV protocol updates",
"NOTE:Changed"
Modified: CalendarServer/trunk/txdav/carddav/iaddressbookstore.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/iaddressbookstore.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/txdav/carddav/iaddressbookstore.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -1,6 +1,6 @@
# -*- test-case-name: txdav.carddav.datastore,txdav.carddav.datastore.test.test_sql.AddressBookSQLStorageTests -*-
##
-# Copyright (c) 2010 Apple Inc. All rights reserved.
+# Copyright (c) 2010-2011 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -257,14 +257,6 @@
@return: a C{VCARD} L{VComponent}.
"""
- def vCardText():
- """
- Retrieve the vCard text data for this addressbook object.
-
- @return: a string containing vCard data for a single
- addressbook object.
- """
-
def uid():
"""
Retrieve the UID for this addressbook object.
Modified: CalendarServer/trunk/txdav/common/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/file.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/txdav/common/datastore/file.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -927,7 +927,7 @@
raise NotImplementedError
- def text(self):
+ def _text(self):
raise NotImplementedError
Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py 2011-06-22 20:52:55 UTC (rev 7649)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py 2011-06-23 16:11:19 UTC (rev 7650)
@@ -435,7 +435,7 @@
results = (yield self.eventsOlderThan(cutoff, batchSize=batchSize))
count = 0
- for uid, calendarName, eventName, maxDate in results:
+ for uid, calendarName, eventName, _ignore_maxDate in results:
home = (yield self.calendarHomeWithUID(uid))
calendar = (yield home.childWithName(calendarName))
(yield calendar.removeObjectResourceWithName(eventName))
@@ -2407,7 +2407,7 @@
@inlineCallbacks
- def text(self):
+ def _text(self):
if self._objectText is None:
text = (
yield self._textByIDQuery.on(self._txn,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110623/858e01f9/attachment-0001.html>
More information about the calendarserver-changes
mailing list