[CalendarServer-changes] [4486] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu Aug 6 13:56:49 PDT 2009
Revision: 4486
http://trac.macosforge.org/projects/calendarserver/changeset/4486
Author: cdaboo at apple.com
Date: 2009-08-06 13:56:48 -0700 (Thu, 06 Aug 2009)
Log Message:
-----------
Revert r4480.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tap/caldav.py
CalendarServer/trunk/calendarserver/tools/export.py
CalendarServer/trunk/calendarserver/tools/warmup.py
CalendarServer/trunk/lib-patches/Twisted/twisted.application.app.patch
CalendarServer/trunk/lib-patches/Twisted/twisted.mail.imap4.patch
CalendarServer/trunk/lib-patches/Twisted/twisted.python.util.patch
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.auth.digest.patch
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.report.patch
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.error.patch
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch
CalendarServer/trunk/twistedcaldav/caldavxml.py
CalendarServer/trunk/twistedcaldav/directory/calendar.py
CalendarServer/trunk/twistedcaldav/directory/directory.py
CalendarServer/trunk/twistedcaldav/directory/principal.py
CalendarServer/trunk/twistedcaldav/directory/test/test_principal.py
CalendarServer/trunk/twistedcaldav/extensions.py
CalendarServer/trunk/twistedcaldav/freebusyurl.py
CalendarServer/trunk/twistedcaldav/icaldav.py
CalendarServer/trunk/twistedcaldav/index.py
CalendarServer/trunk/twistedcaldav/log.py
CalendarServer/trunk/twistedcaldav/memcacheprops.py
CalendarServer/trunk/twistedcaldav/method/delete_common.py
CalendarServer/trunk/twistedcaldav/method/get.py
CalendarServer/trunk/twistedcaldav/method/propfind.py
CalendarServer/trunk/twistedcaldav/method/put_common.py
CalendarServer/trunk/twistedcaldav/method/report_calquery.py
CalendarServer/trunk/twistedcaldav/method/report_common.py
CalendarServer/trunk/twistedcaldav/resource.py
CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py
CalendarServer/trunk/twistedcaldav/scheduling/utils.py
CalendarServer/trunk/twistedcaldav/static.py
CalendarServer/trunk/twistedcaldav/test/test_collectioncontents.py
CalendarServer/trunk/twistedcaldav/test/test_memcacheprops.py
CalendarServer/trunk/twistedcaldav/test/test_sql.py
CalendarServer/trunk/twistedcaldav/test/test_static.py
Removed Paths:
-------------
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.static.patch
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.test.test_resource.patch
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.static.patch
Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -597,6 +597,14 @@
directory,
)
+ self.log_info("Setting up calendar collection: %r"
+ % (self.calendarResourceClass,))
+
+ calendarCollection = self.calendarResourceClass(
+ os.path.join(config.DocumentRoot, "calendars"),
+ directory, "/calendars/",
+ )
+
self.log_info("Setting up root resource: %r"
% (self.rootResourceClass,))
@@ -604,18 +612,10 @@
config.DocumentRoot,
principalCollections=(principalCollection,),
)
+
root.putChild("principals", principalCollection)
+ root.putChild("calendars", calendarCollection)
- d = self.calendarResourceClass.fetch(None,
- os.path.join(config.DocumentRoot, "calendars"),
- directory, "/calendars/")
-
- def _installCalendars(calendarCollection):
- self.log_info("Setting up calendar collection: %r"
- % (self.calendarResourceClass,))
- root.putChild("calendars", calendarCollection)
- d.addCallback(_installCalendars)
-
for name, info in config.Aliases.iteritems():
if os.path.sep in name or not info.get("path", None):
self.log_error("Invalid alias: %s" % (name,))
Modified: CalendarServer/trunk/calendarserver/tools/export.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/export.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/calendarserver/tools/export.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -37,8 +37,6 @@
from os.path import dirname, abspath
from twistedcaldav.config import ConfigurationError
-from twisted.internet.defer import gatherResults
-
from twistedcaldav.ical import Component as iComponent, Property as iProperty
from twistedcaldav.ical import iCalendarProductID
from twistedcaldav.resource import isCalendarCollectionResource
@@ -155,12 +153,6 @@
sys.stdout.write("%s\n" % (e,))
sys.exit(1)
- def _gotChildren(children):
- for childName in children:
- child = calendarHome.getChild(childName)
- if isCalendarCollectionResource(child):
- collections.add(child)
-
for record in records:
recordType, shortName = record
calendarHome = config.directory.calendarHomeForShortName(recordType, shortName)
@@ -169,60 +161,63 @@
sys.exit(1)
calendarHomes.add(calendarHome)
- d = gatherResults([calendarHome.listChildren().addCallback(_gotChildren) for calendarHome in calendarHomes])
- def _finish(_):
- try:
- calendar = iComponent("VCALENDAR")
- calendar.addProperty(iProperty("VERSION", "2.0"))
- calendar.addProperty(iProperty("PRODID", iCalendarProductID))
+ for calendarHome in calendarHomes:
+ for childName in calendarHome.listChildren():
+ child = calendarHome.getChild(childName)
+ if isCalendarCollectionResource(child):
+ collections.add(child)
- uids = set()
- tzids = set()
+ try:
+ calendar = iComponent("VCALENDAR")
+ calendar.addProperty(iProperty("VERSION", "2.0"))
+ calendar.addProperty(iProperty("PRODID", iCalendarProductID))
- for collection in collections:
- for name, uid, type in collection.index().indexedSearch(None):
- child = collection.getChild(name)
- childData = child.iCalendarText()
+ uids = set()
+ tzids = set()
- try:
- childCalendar = iComponent.fromString(childData)
- except ValueError:
- continue
- assert childCalendar.name() == "VCALENDAR"
+ for collection in collections:
+ for name, uid, type in collection.index().indexedSearch(None):
+ child = collection.getChild(name)
+ childData = child.iCalendarText()
- if uid in uids:
- sys.stderr.write("Skipping duplicate event UID %r from %s\n" % (uid, collection.fp.path))
- continue
- else:
- uids.add(uid)
+ try:
+ childCalendar = iComponent.fromString(childData)
+ except ValueError:
+ continue
+ assert childCalendar.name() == "VCALENDAR"
- for component in childCalendar.subcomponents():
- # Only insert VTIMEZONEs once
- if component.name() == "VTIMEZONE":
- tzid = component.propertyValue("TZID")
- if tzid in tzids:
- continue
- else:
- tzids.add(tzid)
+ if uid in uids:
+ sys.stderr.write("Skipping duplicate event UID %r from %s\n" % (uid, collection.fp.path))
+ continue
+ else:
+ uids.add(uid)
- calendar.addComponent(component)
+ for component in childCalendar.subcomponents():
+ # Only insert VTIMEZONEs once
+ if component.name() == "VTIMEZONE":
+ tzid = component.propertyValue("TZID")
+ if tzid in tzids:
+ continue
+ else:
+ tzids.add(tzid)
- calendarData = str(calendar)
+ calendar.addComponent(component)
- if outputFileName:
- try:
- output = open(outputFileName, "w")
- except IOError, e:
- sys.stderr.write("Unable to open output file for writing %s: %s\n" % (outputFileName, e))
- sys.exit(1)
- else:
- output = sys.stdout
+ calendarData = str(calendar)
- output.write(calendarData)
+ if outputFileName:
+ try:
+ output = open(outputFileName, "w")
+ except IOError, e:
+ sys.stderr.write("Unable to open output file for writing %s: %s\n" % (outputFileName, e))
+ sys.exit(1)
+ else:
+ output = sys.stdout
- except UsageError, e:
- usage(e)
- return d.addCallback(_finish)
+ output.write(calendarData)
+ except UsageError, e:
+ usage(e)
+
if __name__ == "__main__":
main()
Modified: CalendarServer/trunk/calendarserver/tools/warmup.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/warmup.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/calendarserver/tools/warmup.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -33,8 +33,6 @@
from os.path import dirname, abspath
from twistedcaldav.config import ConfigurationError
-from twisted.internet.defer import gatherResults
-
from twistedcaldav.resource import isPseudoCalendarCollectionResource
from twistedcaldav.static import CalDAVFile, CalendarHomeFile
from twistedcaldav.directory.directory import DirectoryService
@@ -154,38 +152,31 @@
calendarCollections = set()
- def _gotChildren(children):
- for childName in children:
- child = calendarHome.getChild(childName)
- if isPseudoCalendarCollectionResource(child):
- calendarCollections.add(child)
- ds = []
for calendarHome in calendarHomes:
#print calendarHome
#sys.stdout.write("*")
readProperties(calendarHome)
- ds.append(calendarHome.listChildren().addCallback(_gotChildren))
- d = gatherResults(ds)
+ for childName in calendarHome.listChildren():
+ child = calendarHome.getChild(childName)
+ if isPseudoCalendarCollectionResource(child):
+ calendarCollections.add(child)
- def _finish(_):
- for calendarCollection in calendarCollections:
- try:
- for name, uid, type in calendarCollection.index().indexedSearch(None):
- child = calendarCollection.getChild(name)
+ for calendarCollection in calendarCollections:
+ try:
+ for name, uid, type in calendarCollection.index().indexedSearch(None):
+ child = calendarCollection.getChild(name)
- #sys.stdout.write("+")
- d = child.iCalendarText()
+ #sys.stdout.write("+")
+ childCalendar = child.iCalendarText()
- readProperties(child)
+ readProperties(child)
- except sqlite3.OperationalError:
- # Outbox doesn't live on disk
- if calendarCollection.fp.basename() != "outbox":
- raise
+ except sqlite3.OperationalError:
+ # Outbox doesn't live on disk
+ if calendarCollection.fp.basename() != "outbox":
+ raise
- return d.addCallback(_finish)
-
def readProperties(resource):
#sys.stdout.write("-")
for qname in resource.deadProperties().list():
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.application.app.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.application.app.patch 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.application.app.patch 2009-08-06 20:56:48 UTC (rev 4486)
@@ -1,6 +1,7 @@
-=== modified file 'twisted/application/app.py'
---- twisted/application/app.py 2008-12-14 22:09:07 +0000
-+++ twisted/application/app.py 2009-07-15 23:30:17 +0000
+Index: twisted/application/app.py
+===================================================================
+--- twisted/application/app.py (revision 26969)
++++ twisted/application/app.py (working copy)
@@ -241,7 +241,11 @@
@param application: The application on which to check for an
L{ILogObserver}.
@@ -14,24 +15,25 @@
if observer is None:
observer = self._getLogObserver()
-@@ -408,8 +412,6 @@
+@@ -408,9 +412,7 @@
Run the application.
"""
self.preApplication()
- self.application = self.createOrGetApplication()
+
-
-
getLogObserverLegacy = getattr(self, 'getLogObserver', None)
if getLogObserverLegacy is not None:
-@@ -418,7 +420,9 @@
+ warnings.warn("Specifying a log observer with getLogObserver is "
+@@ -418,8 +420,10 @@
category=DeprecationWarning)
self.startLogging(self.getLogObserver())
else:
- self.logger.start(self.application)
+ self.logger.start(None)
+
++ self.application = self.createOrGetApplication()
+
-+ self.application = self.createOrGetApplication()
-
self.postApplication()
self.logger.stop()
-
+
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.mail.imap4.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.mail.imap4.patch 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.mail.imap4.patch 2009-08-06 20:56:48 UTC (rev 4486)
@@ -1,6 +1,7 @@
-=== modified file 'twisted/mail/imap4.py'
---- twisted/mail/imap4.py 2009-03-23 11:02:59 +0000
-+++ twisted/mail/imap4.py 2009-07-15 23:30:17 +0000
+Index: twisted/mail/imap4.py
+===================================================================
+--- twisted/mail/imap4.py (revision 26969)
++++ twisted/mail/imap4.py (working copy)
@@ -333,7 +333,7 @@
@@ -19,4 +20,3 @@
class MailboxException(IMAP4Exception): pass
-
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.python.util.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.python.util.patch 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.python.util.patch 2009-08-06 20:56:48 UTC (rev 4486)
@@ -1,7 +1,8 @@
-=== modified file 'twisted/python/util.py'
---- twisted/python/util.py 2009-03-30 13:33:33 +0000
-+++ twisted/python/util.py 2009-07-15 23:30:18 +0000
-@@ -569,7 +569,27 @@
+Index: twisted/python/util.py
+===================================================================
+--- twisted/python/util.py (revision 26969)
++++ twisted/python/util.py (working copy)
+@@ -569,9 +569,29 @@
L2.sort()
return [e[2] for e in L2]
@@ -17,8 +18,8 @@
+if sys.platform == "darwin" and hasCtypes:
+ import pwd
+ libc = cdll.LoadLibrary(find_library("libc"))
-+ def initgroups(uid, primaryGid):
-+ """
+ def initgroups(uid, primaryGid):
+ """
+ Call initgroups with ctypes.
+ """
+ c_gid = c_int(primaryGid)
@@ -27,7 +28,8 @@
+ return libc.initgroups(c_username, c_gid)
+
+elif pwd is None or grp is None or setgroups is None or getgroups is None:
- def initgroups(uid, primaryGid):
- """
++ def initgroups(uid, primaryGid):
++ """
Do nothing.
-
+
+ Underlying platform support require to manipulate groups is missing.
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.auth.digest.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.auth.digest.patch 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.auth.digest.patch 2009-08-06 20:56:48 UTC (rev 4486)
@@ -1,6 +1,7 @@
-=== modified file 'twisted/web2/auth/digest.py'
---- twisted/web2/auth/digest.py 2009-04-20 17:38:06 +0000
-+++ twisted/web2/auth/digest.py 2009-07-15 23:30:18 +0000
+Index: twisted/web2/auth/digest.py
+===================================================================
+--- twisted/web2/auth/digest.py (revision 26969)
++++ twisted/web2/auth/digest.py (working copy)
@@ -138,11 +138,15 @@
implements(credentials.IUsernameHashedPassword,
IUsernameDigestHash)
@@ -18,7 +19,7 @@
def checkPassword(self, password):
response = self.fields.get('response')
-@@ -155,10 +159,22 @@
+@@ -155,11 +159,23 @@
expected = calcResponse(
calcHA1(algo, self.username, self.realm, password, nonce, cnonce),
@@ -29,7 +30,7 @@
- return expected == response
+ if expected == response:
+ return True
-+
+
+ # IE7 sends cnonce and nc values, but auth fails if they are used.
+ # So try again without them...
+ # They can be omitted for backwards compatibility [RFC 2069].
@@ -40,9 +41,10 @@
+ )
+ if expected == response:
+ return True
-
++
def checkHash(self, digestHash):
response = self.fields.get('response')
+ uri = self.fields.get('uri')
@@ -171,7 +187,7 @@
expected = calcResponse(
@@ -78,4 +80,3 @@
+ self.realm,
+ auth,
+ originalMethod))
-
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.report.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.report.patch 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.report.patch 2009-08-06 20:56:48 UTC (rev 4486)
@@ -1,6 +1,7 @@
-=== modified file 'twisted/web2/dav/method/report.py'
---- twisted/web2/dav/method/report.py 2009-04-20 17:38:06 +0000
-+++ twisted/web2/dav/method/report.py 2009-07-15 23:30:18 +0000
+Index: twisted/web2/dav/method/report.py
+===================================================================
+--- twisted/web2/dav/method/report.py (revision 26969)
++++ twisted/web2/dav/method/report.py (working copy)
@@ -94,8 +94,9 @@
namespace = doc.root_element.namespace
name = doc.root_element.name
@@ -31,4 +32,3 @@
try:
method = getattr(self, method_name)
-
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch 2009-08-06 20:56:48 UTC (rev 4486)
@@ -1,6 +1,7 @@
-=== modified file 'twisted/web2/dav/resource.py'
---- twisted/web2/dav/resource.py 2009-05-07 20:35:07 +0000
-+++ twisted/web2/dav/resource.py 2009-07-15 23:30:18 +0000
+Index: twisted/web2/dav/resource.py
+===================================================================
+--- twisted/web2/dav/resource.py (revision 26969)
++++ twisted/web2/dav/resource.py (working copy)
@@ -49,12 +49,14 @@
if not hasattr(__builtin__, "frozenset"):
import sets.ImmutableSet as frozenset
@@ -18,56 +19,7 @@
from twisted.internet import reactor
from twisted.web2 import responsecode
from twisted.web2.http import HTTPError, RedirectResponse, StatusResponse
-@@ -578,7 +580,6 @@
-
- completionDeferred = Deferred()
- basepath = request.urlForResource(self)
-- children = list(self.listChildren())
-
- def checkPrivilegesError(failure):
- failure.trap(AccessDeniedError)
-@@ -595,7 +596,7 @@
- d.addCallback(lambda _: child)
- return d
-
-- def gotChild(child, childpath):
-+ def gotChild(child, childpath, children):
- if child is None:
- callback(None, childpath + "/")
- else:
-@@ -603,14 +604,15 @@
- callback(child, childpath + "/")
- if depth == "infinity":
- d = child.findChildren(depth, request, callback, privileges)
-- d.addCallback(lambda x: reactor.callLater(0, getChild))
-+ d.addCallback(lambda x: reactor.callLater(0, getChild, children))
- return d
- else:
- callback(child, childpath)
-
-- reactor.callLater(0, getChild)
-+ reactor.callLater(0, getChild, children)
-
-- def getChild():
-+ def getChild(children):
-+ children = list(children)
- try:
- childname = children.pop()
- except IndexError:
-@@ -619,10 +621,10 @@
- childpath = joinURL(basepath, childname)
- d = request.locateChildResource(self, childname)
- d.addCallback(checkPrivileges)
-- d.addCallbacks(gotChild, checkPrivilegesError, (childpath,))
-+ d.addCallbacks(gotChild, checkPrivilegesError, (childpath, children))
- d.addErrback(completionDeferred.errback)
-
-- getChild()
-+ self.listChildren().addCallback(getChild)
-
- return completionDeferred
-
-@@ -642,39 +644,41 @@
+@@ -642,41 +644,43 @@
# Authentication
##
@@ -97,15 +49,10 @@
- # "Authorization will not help" according to RFC2616
- #
- raise HTTPError(response)
--
+
- d = self.checkPrivileges(request, privileges, recurse)
- d.addErrback(onErrors)
- return d
--
-- d = maybeDeferred(self.authenticate, request)
-- d.addCallback(onAuth)
-- return d
-+
+ try:
+ yield self.authenticate(request)
+ except (UnauthorizedLogin, LoginFailed), e:
@@ -115,7 +62,10 @@
+ request.remoteAddr
+ ))
+ raise HTTPError(response)
-+
+
+- d = maybeDeferred(self.authenticate, request)
+- d.addCallback(onAuth)
+- return d
+ try:
+ yield self.checkPrivileges(request, privileges, recurse)
+ except AccessDeniedError, e:
@@ -134,10 +84,12 @@
+ # "Authorization will not help" according to RFC2616
+ #
+ raise HTTPError(response)
-+
++
def authenticate(self, request):
+ if not (
+ hasattr(request, 'portal') and
@@ -1880,7 +1884,7 @@
# If this is a collection and the URI doesn't end in "/", redirect.
#
@@ -147,4 +99,3 @@
def setHeaders(response):
response = IResponse(response)
-
Deleted: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.static.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.static.patch 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.static.patch 2009-08-06 20:56:48 UTC (rev 4486)
@@ -1,28 +0,0 @@
-=== modified file 'twisted/web2/dav/static.py'
---- twisted/web2/dav/static.py 2009-04-20 17:38:06 +0000
-+++ twisted/web2/dav/static.py 2009-07-15 23:30:18 +0000
-@@ -53,6 +53,14 @@
-
- Extends twisted.web2.static.File to handle WebDAV methods.
- """
-+ @classmethod
-+ def fetch(cls, request, path, *args, **kwargs):
-+ """
-+ stuff etc
-+ """
-+ return succeed(cls(path, *args, **kwargs))
-+
-+
- def __init__(
- self, path,
- defaultType="text/plain", indexNames=None,
-@@ -192,7 +200,7 @@
- return (self.createSimilarFile(self.fp.child(path).path), segments[1:])
-
- def createSimilarFile(self, path):
-- return self.__class__(
-+ return self.__class__.fetch(None,
- path, defaultType=self.defaultType, indexNames=self.indexNames[:],
- principalCollections=self.principalCollections())
-
-
Deleted: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.test.test_resource.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.test.test_resource.patch 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.test.test_resource.patch 2009-08-06 20:56:48 UTC (rev 4486)
@@ -1,13 +0,0 @@
-=== modified file 'twisted/web2/dav/test/test_resource.py'
---- twisted/web2/dav/test/test_resource.py 2009-05-07 20:35:07 +0000
-+++ twisted/web2/dav/test/test_resource.py 2009-07-15 23:30:18 +0000
-@@ -376,7 +376,7 @@
- return self.children is not None
-
- def listChildren(self):
-- return self.children.keys()
-+ return succeed(self.children.keys())
-
- def supportedPrivileges(self, request):
- return succeed(davPrivilegeSet)
-
Deleted: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch 2009-08-06 20:56:48 UTC (rev 4486)
@@ -1,20 +0,0 @@
-=== modified file 'twisted/web2/dav/xattrprops.py'
---- twisted/web2/dav/xattrprops.py 2009-06-03 23:46:41 +0000
-+++ twisted/web2/dav/xattrprops.py 2009-07-15 23:30:18 +0000
-@@ -49,6 +49,7 @@
-
- from twisted.python.util import untilConcludes
- from twisted.python.failure import Failure
-+from twisted.internet.defer import succeed
- from twisted.python import log
- from twisted.web2 import responsecode
- from twisted.web2.http import HTTPError, StatusResponse
-@@ -188,6 +189,7 @@
-
- # Update the resource because we've modified it
- self.resource.fp.restat()
-+ return succeed(None)
-
-
- def delete(self, qname):
-
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.error.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.error.patch 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.error.patch 2009-08-06 20:56:48 UTC (rev 4486)
@@ -1,6 +1,7 @@
-=== modified file 'twisted/web2/error.py'
---- twisted/web2/error.py 2005-11-22 22:59:59 +0000
-+++ twisted/web2/error.py 2009-07-15 23:30:18 +0000
+Index: twisted/web2/error.py
+===================================================================
+--- twisted/web2/error.py (revision 26969)
++++ twisted/web2/error.py (working copy)
@@ -92,7 +92,7 @@
"<body><h1>%s</h1>%s</body></html>") % (
response.code, title, title, message)
@@ -10,4 +11,3 @@
response.stream = stream.MemoryStream(body)
return response
-
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch 2009-08-06 20:56:48 UTC (rev 4486)
@@ -28,4 +28,3 @@
# This is where CONNECT would go if we wanted it
return None
-
Deleted: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.static.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.static.patch 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.static.patch 2009-08-06 20:56:48 UTC (rev 4486)
@@ -1,69 +0,0 @@
-=== modified file 'twisted/web2/static.py'
---- twisted/web2/static.py 2009-04-20 17:38:06 +0000
-+++ twisted/web2/static.py 2009-07-15 23:30:18 +0000
-@@ -16,7 +16,7 @@
-
- # Twisted Imports
- from twisted.python import filepath
--from twisted.internet.defer import maybeDeferred
-+from twisted.internet.defer import maybeDeferred, succeed
- from zope.interface import implements
-
- class MetaDataMixin(object):
-@@ -291,12 +291,13 @@
- self.ignoredExts.append(ext)
-
- def directoryListing(self):
-- return dirlist.DirectoryLister(self.fp.path,
-- self.listChildren(),
-- self.contentTypes,
-- self.contentEncodings,
-- self.defaultType)
--
-+ return self.listChildren().addCallback(lambda children: dirlist.DirectoryLister(
-+ self.fp.path,
-+ children,
-+ self.contentTypes,
-+ self.contentEncodings,
-+ self.defaultType))
-+
- def putChild(self, name, child):
- """
- Register a child with the given name with this resource.
-@@ -329,7 +330,7 @@
- children = self.putChildren.keys()
- if self.fp.isdir():
- children += [c for c in self.fp.listdir() if c not in children]
-- return children
-+ return succeed(children)
-
- def locateChild(self, req, segments):
- """
-@@ -387,17 +388,17 @@
- ifp = self.fp.childSearchPreauth(*self.indexNames)
- if ifp:
- # Render from the index file
-- standin = self.createSimilarFile(ifp.path)
-+ standin = self.createSimilarFile(ifp.path).render(req)
- else:
- # Render from a DirectoryLister
-- standin = dirlist.DirectoryLister(
-- self.fp.path,
-- self.listChildren(),
-- self.contentTypes,
-- self.contentEncodings,
-- self.defaultType
-- )
-- return standin.render(req)
-+ return self.listChildren().addCallback(
-+ lambda children: dirlist.DirectoryLister(
-+ self.fp.path,
-+ self.listChildren(),
-+ self.contentTypes,
-+ self.contentEncodings,
-+ self.defaultType
-+ ).render(req))
-
- try:
- f = self.fp.open()
-
Modified: CalendarServer/trunk/twistedcaldav/caldavxml.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/caldavxml.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/caldavxml.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -497,7 +497,7 @@
@param timezone: the L{Component} the VTIMEZONE to use for floating/all-day.
@return: an L{CalendarData} with the (filtered) calendar data.
"""
- return resource.iCalendarText().addCallback(self.elementFromCalendar, timezone)
+ return self.elementFromCalendar(resource.iCalendarText(), timezone)
def elementFromCalendar(self, calendar, timezone=None):
"""
@@ -526,7 +526,7 @@
@param timezone: the L{Component} the VTIMEZONE to use for floating/all-day.
@return: an L{CalendarData} with the (filtered) calendar data.
"""
- return resource.iCalendarText().addCallback(self.elementFromCalendarWithAccessRestrictions, access, timezone)
+ return self.elementFromCalendarWithAccessRestrictions(resource.iCalendarText(), access, timezone)
def elementFromCalendarWithAccessRestrictions(self, calendar, access, timezone=None):
"""
Modified: CalendarServer/trunk/twistedcaldav/directory/calendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/calendar.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/directory/calendar.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -27,7 +27,7 @@
"DirectoryCalendarHomeResource",
]
-from twisted.internet.defer import succeed, inlineCallbacks, returnValue, gatherResults
+from twisted.internet.defer import succeed, inlineCallbacks, returnValue
from twisted.web2 import responsecode
from twisted.web2.dav import davxml
from twisted.web2.http import HTTPError
@@ -102,7 +102,7 @@
return self.putChildren.get(name, None)
def listChildren(self):
- return succeed(self.directory.recordTypes())
+ return self.directory.recordTypes()
def principalCollections(self):
# FIXME: directory.principalCollection smells like a hack
@@ -117,7 +117,7 @@
def homeForDirectoryRecord(self, record):
uidResource = self.getChild(uidsResourceName)
if uidResource is None:
- return succeed(None)
+ return None
else:
return uidResource.getChild(record.uid)
@@ -172,10 +172,10 @@
for shortName in record.shortNames:
yield shortName
- return succeed(_recordShortnameExpand())
+ return _recordShortnameExpand()
else:
# Not a listable collection
- return fail(HTTPError(responsecode.FORBIDDEN))
+ raise HTTPError(responsecode.FORBIDDEN)
def createSimilarFile(self, path):
raise HTTPError(responsecode.NOT_FOUND)
@@ -227,7 +227,7 @@
def listChildren(self):
# Not a listable collection
- return fail(HTTPError(responsecode.FORBIDDEN))
+ raise HTTPError(responsecode.FORBIDDEN)
##
# DAV
@@ -251,7 +251,6 @@
"""
Calendar home collection resource.
"""
-
def __init__(self, parent, record):
"""
@param path: the path to the file which will back the resource.
@@ -264,13 +263,31 @@
self.record = record
self.parent = parent
+ # Cache children which must be of a specific type
+ childlist = (
+ ("inbox" , ScheduleInboxResource ),
+ ("outbox", ScheduleOutboxResource),
+ )
+ if config.EnableDropBox:
+ childlist += (
+ ("dropbox", DropBoxHomeResource),
+ )
+ if config.FreeBusyURL.Enabled:
+ childlist += (
+ ("freebusy", FreeBusyURLResource),
+ )
+ for name, cls in childlist:
+ child = self.provisionChild(name)
+ assert isinstance(child, cls), "Child %r is not a %s: %r" % (name, cls.__name__, child)
+ self.putChild(name, child)
+
def provisionDefaultCalendars(self):
# Disable notifications during provisioning
if hasattr(self, "clientNotifier"):
self.clientNotifier.disableNotify()
- def setupFreeBusy(_, child):
+ def setupFreeBusy(_):
# Default calendar is initially opaque to freebusy
child.writeDeadProperty(caldavxml.ScheduleCalendarTransp(caldavxml.Opaque()))
@@ -290,17 +307,15 @@
return self
try:
- d = self.provision()
+ self.provision()
childName = "calendar"
childURL = joinURL(self.url(), childName)
- d.addCallback(lambda _: self.provisionChild(childName))
-
- def _makeChild(child):
- assert isinstance(child, CalDAVResource), "Child %r is not a %s: %r" % (childName, CalDAVResource.__name__, child)
- return child.createCalendarCollection().addCallback(setupFreeBusy, child)
+ child = self.provisionChild(childName)
+ assert isinstance(child, CalDAVResource), "Child %r is not a %s: %r" % (childName, CalDAVResource.__name__, child)
- d.addCallback(_makeChild)
+ d = child.createCalendarCollection()
+ d.addCallback(setupFreeBusy)
except:
# We want to make sure to re-enable notifications, so do so
# if there is an immediate exception above, or via errback, below
Modified: CalendarServer/trunk/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/directory.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/directory/directory.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -107,16 +107,13 @@
credentials.authzPrincipal.principalURL(),
)
else:
- d = credentials.authnPrincipal.record.verifyCredentials(credentials.credentials)
- def _verify(authed):
- if authed:
- return (
- credentials.authnPrincipal.principalURL(),
- credentials.authzPrincipal.principalURL(),
- )
- else:
- raise UnauthorizedLogin("Incorrect credentials for %s" % (credentials.credentials.username,))
- return d.addCallback(_verify)
+ if credentials.authnPrincipal.record.verifyCredentials(credentials.credentials):
+ return (
+ credentials.authnPrincipal.principalURL(),
+ credentials.authzPrincipal.principalURL(),
+ )
+ else:
+ raise UnauthorizedLogin("Incorrect credentials for %s" % (credentials.credentials.username,))
def recordTypes(self):
raise NotImplementedError("Subclass must implement recordTypes()")
Modified: CalendarServer/trunk/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/principal.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -37,7 +37,7 @@
from twisted.cred.credentials import UsernamePassword
from twisted.python.failure import Failure
from twisted.internet.defer import inlineCallbacks, returnValue
-from twisted.internet.defer import succeed, fail
+from twisted.internet.defer import succeed
from twisted.web2.auth.digest import DigestedCredentials
from twisted.web2 import responsecode
from twisted.web2.http import HTTPError
@@ -348,7 +348,7 @@
return self.putChildren.get(name, None)
def listChildren(self):
- return succeed(self.directory.recordTypes())
+ return self.directory.recordTypes()
##
# ACL
@@ -405,10 +405,10 @@
for shortName in record.shortNames:
yield shortName
- return succeed(_recordShortnameExpand())
+ return _recordShortnameExpand()
else:
# Not a listable collection
- return fail(HTTPError(responsecode.FORBIDDEN))
+ raise HTTPError(responsecode.FORBIDDEN)
##
# ACL
@@ -479,7 +479,7 @@
def listChildren(self):
# Not a listable collection
- return fail(HTTPError(responsecode.FORBIDDEN))
+ raise HTTPError(responsecode.FORBIDDEN)
##
# ACL
@@ -811,7 +811,7 @@
return None
def listChildren(self):
- return succeed(())
+ return ()
class DirectoryCalendarPrincipalResource (DirectoryPrincipalResource, CalendarPrincipalResource):
@@ -838,13 +838,10 @@
returnValue(result)
def extraDirectoryBodyItems(self, request):
- d = self.calendarHomeURLs()
- def _gotURLs(homeURLs):
- return "".join((
- """\nCalendar homes:\n""" , format_list(format_link(u) for u in homeURLs),
- """\nCalendar user addresses:\n""" , format_list(format_link(a) for a in self.calendarUserAddresses()),
- ))
- return d.addCallbacks(_gotURLs)
+ return "".join((
+ """\nCalendar homes:\n""" , format_list(format_link(u) for u in self.calendarHomeURLs()),
+ """\nCalendar user addresses:\n""" , format_list(format_link(a) for a in self.calendarUserAddresses()),
+ ))
##
# CalDAV
@@ -880,22 +877,22 @@
return False
def scheduleInbox(self, request):
- d = self.calendarHome()
- def _gotHome(home):
- if home is None:
- return None
- return home.getChild("inbox")
+ home = self.calendarHome()
+ if home is None:
+ return succeed(None)
- return d.addCallback(_gotHome)
+ inbox = home.getChild("inbox")
+ if inbox is None:
+ return succeed(None)
+ return succeed(inbox)
+
def calendarHomeURLs(self):
- d = self.calendarHome()
- def _gotHome(home):
- if home is None:
- return ()
- else:
- return (home.url(),)
- return d.addCallback(_gotHome)
+ home = self.calendarHome()
+ if home is None:
+ return ()
+ else:
+ return (home.url(),)
def scheduleInboxURL(self):
return self._homeChildURL("inbox/")
@@ -910,13 +907,11 @@
return None
def _homeChildURL(self, name):
- d = self.calendarHome()
- def _gotHome(home):
- if home is None:
- return None
- else:
- return joinURL(home.url(), name)
- return d.addCallback(_gotHome)
+ home = self.calendarHome()
+ if home is None:
+ return None
+ else:
+ return joinURL(home.url(), name)
def calendarHome(self):
# FIXME: self.record.service.calendarHomesCollection smells like a hack
@@ -925,7 +920,7 @@
if hasattr(service, "calendarHomesCollection"):
return service.calendarHomesCollection.homeForDirectoryRecord(self.record)
else:
- return succeed(None)
+ return None
##
@@ -943,9 +938,10 @@
def listChildren(self):
if config.EnableProxyPrincipals:
- return succeed(("calendar-proxy-read", "calendar-proxy-write"))
+ return ("calendar-proxy-read", "calendar-proxy-write")
else:
- return succeed(())
+ return ()
+
##
# Utilities
##
Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_principal.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_principal.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -17,7 +17,7 @@
import os
from twisted.cred.credentials import UsernamePassword
-from twisted.internet.defer import inlineCallbacks, gatherResults
+from twisted.internet.defer import inlineCallbacks
from twisted.web2.dav import davxml
from twisted.web2.dav.fileop import rmdir
from twisted.web2.dav.resource import AccessDeniedError
@@ -105,39 +105,34 @@
principalCollections = provisioningResource.principalCollections()
self.assertEquals(set((provisioningURL,)), set(pc.principalCollectionURL() for pc in principalCollections))
- d = provisioningResource.listChildren()
- def _gotProvisioningChildren(children):
- recordTypes = set(children)
- self.assertEquals(recordTypes, set(directory.recordTypes()))
+ recordTypes = set(provisioningResource.listChildren())
+ self.assertEquals(recordTypes, set(directory.recordTypes()))
- for recordType in recordTypes:
- #print " -> %s" % (recordType,)
- typeResource = provisioningResource.getChild(recordType)
- self.failUnless(isinstance(typeResource, DirectoryPrincipalTypeProvisioningResource))
+ for recordType in recordTypes:
+ #print " -> %s" % (recordType,)
+ typeResource = provisioningResource.getChild(recordType)
+ self.failUnless(isinstance(typeResource, DirectoryPrincipalTypeProvisioningResource))
- typeURL = provisioningURL + recordType + "/"
- self.assertEquals(typeURL, typeResource.principalCollectionURL())
+ typeURL = provisioningURL + recordType + "/"
+ self.assertEquals(typeURL, typeResource.principalCollectionURL())
- principalCollections = typeResource.principalCollections()
- self.assertEquals(set((provisioningURL,)), set(pc.principalCollectionURL() for pc in principalCollections))
- d = typeResource.listChildren()
- def _gotTypeChildren(children):
- shortNames = set(children)
- self.assertEquals(shortNames, set(r.shortNames[0] for r in directory.listRecords(recordType)))
+ principalCollections = typeResource.principalCollections()
+ self.assertEquals(set((provisioningURL,)), set(pc.principalCollectionURL() for pc in principalCollections))
- for shortName in shortNames:
- #print " -> %s" % (shortName,)
- recordResource = typeResource.getChild(shortName)
- self.failUnless(isinstance(recordResource, DirectoryPrincipalResource))
+ shortNames = set(typeResource.listChildren())
+ self.assertEquals(shortNames, set(r.shortNames[0] for r in directory.listRecords(recordType)))
- recordURL = typeURL + shortName + "/"
- self.assertIn(recordURL, (recordResource.principalURL(),) + tuple(recordResource.alternateURIs()))
+ for shortName in shortNames:
+ #print " -> %s" % (shortName,)
+ recordResource = typeResource.getChild(shortName)
+ self.failUnless(isinstance(recordResource, DirectoryPrincipalResource))
- principalCollections = recordResource.principalCollections()
- self.assertEquals(set((provisioningURL,)), set(pc.principalCollectionURL() for pc in principalCollections))
-
- return d.addCallback(_gotProvisioningChildren)
+ recordURL = typeURL + shortName + "/"
+ self.assertIn(recordURL, (recordResource.principalURL(),) + tuple(recordResource.alternateURIs()))
+ principalCollections = recordResource.principalCollections()
+ self.assertEquals(set((provisioningURL,)), set(pc.principalCollectionURL() for pc in principalCollections))
+
def test_allRecords(self):
"""
Test of a test routine...
@@ -336,15 +331,12 @@
DirectoryPrincipalResource.scheduleInboxURL(),
DirectoryPrincipalResource.scheduleOutboxURL()
"""
- ds = []
# No calendar home provisioner should result in no calendar homes.
for provisioningResource, recordType, recordResource, record in self._allRecords():
if record.enabledForCalendaring:
- d = recordResource.calendarHomeURLs()
- d.addCallback(lambda u: self.assertEqual(len(u), 0))
- ds.append(d)
- ds.append(recordResource.scheduleInboxURL().addCallback(self.failIf))
- ds.append(recordResource.scheduleOutboxURL().addCallback(self.failIf))
+ self.failIf(tuple(recordResource.calendarHomeURLs()))
+ self.failIf(recordResource.scheduleInboxURL())
+ self.failIf(recordResource.scheduleOutboxURL())
# Need to create a calendar home provisioner for each service.
calendarRootResources = {}
@@ -364,32 +356,33 @@
# Calendar home provisioners should result in calendar homes.
for provisioningResource, recordType, recordResource, record in self._allRecords():
if record.enabledForCalendaring:
- d = gatherResults([recordResource.calendarHomeURLs(),
- recordResource.scheduleInboxURL(),
- recordResource.scheduleOutboxURL()])
- def _gotURLs(homeURLs, inboxURL, outboxURL):
- calendarRootURL = calendarRootResources[record.service.__class__.__name__].url()
+ homeURLs = tuple(recordResource.calendarHomeURLs())
+ self.failUnless(homeURLs)
- self.failUnless(inboxURL)
- self.failUnless(outboxURL)
+ calendarRootURL = calendarRootResources[record.service.__class__.__name__].url()
- for homeURL in homeURLs:
- self.failUnless(homeURL.startswith(calendarRootURL))
+ inboxURL = recordResource.scheduleInboxURL()
+ outboxURL = recordResource.scheduleOutboxURL()
- if inboxURL and inboxURL.startswith(homeURL):
- self.failUnless(len(inboxURL) > len(homeURL))
- self.failUnless(inboxURL.endswith("/"))
- inboxURL = None
+ self.failUnless(inboxURL)
+ self.failUnless(outboxURL)
- if outboxURL and outboxURL.startswith(homeURL):
- self.failUnless(len(outboxURL) > len(homeURL))
- self.failUnless(outboxURL.endswith("/"))
- outboxURL = None
+ for homeURL in homeURLs:
+ self.failUnless(homeURL.startswith(calendarRootURL))
- self.failIf(inboxURL)
- self.failIf(outboxURL)
- return gatherResults(ds)
+ if inboxURL and inboxURL.startswith(homeURL):
+ self.failUnless(len(inboxURL) > len(homeURL))
+ self.failUnless(inboxURL.endswith("/"))
+ inboxURL = None
+ if outboxURL and outboxURL.startswith(homeURL):
+ self.failUnless(len(outboxURL) > len(homeURL))
+ self.failUnless(outboxURL.endswith("/"))
+ outboxURL = None
+
+ self.failIf(inboxURL)
+ self.failIf(outboxURL)
+
@inlineCallbacks
def test_defaultAccessControlList_principals(self):
"""
@@ -410,8 +403,8 @@
for args in _authReadOnlyPrivileges(self, provisioningResource, provisioningResource.principalCollectionURL()):
yield self._checkPrivileges(*args)
- children = yield provisioningResource.listChildren()
- for recordType in children:
+
+ for recordType in provisioningResource.listChildren():
#print " -> %s" % (recordType,)
typeResource = provisioningResource.getChild(recordType)
Modified: CalendarServer/trunk/twistedcaldav/extensions.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/extensions.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/extensions.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -529,7 +529,7 @@
children = []
basepath = request.urlForResource(self)
- childnames = yield self.listChildren()
+ childnames = list(self.listChildren())
for childname in childnames:
if names and childname not in names:
continue
@@ -880,39 +880,37 @@
]
even = Alternator()
- d = self.listChildren()
- def _gotChildren(children):
- for name in sorted(children):
- child = self.getChild(name)
+ for name in sorted(self.listChildren()):
+ child = self.getChild(name)
- url, name, size, lastModified, contentType = self.getChildDirectoryEntry(child, name)
+ url, name, size, lastModified, contentType = self.getChildDirectoryEntry(child, name)
- # FIXME: gray out resources that are not readable
- output.append(
- """<tr class="%(even)s">"""
- """<td><a href="%(url)s">%(name)s</a></td>"""
- """<td align="right">%(size)s</td>"""
- """<td>%(lastModified)s</td>"""
- """<td>%(type)s</td>"""
- """</tr>"""
- % {
- "even": even.state() and "even" or "odd",
- "url": url,
- "name": cgi.escape(name),
- "size": size,
- "lastModified": lastModified,
- "type": contentType,
- }
- )
-
+ # FIXME: gray out resources that are not readable
output.append(
- """</table></div>"""
- """<div class="directory-listing">"""
- """<h1>Properties</h1>"""
- """<table>"""
- """<tr><th>Name</th> <th>Value</th></tr>"""
+ """<tr class="%(even)s">"""
+ """<td><a href="%(url)s">%(name)s</a></td>"""
+ """<td align="right">%(size)s</td>"""
+ """<td>%(lastModified)s</td>"""
+ """<td>%(type)s</td>"""
+ """</tr>"""
+ % {
+ "even": even.state() and "even" or "odd",
+ "url": url,
+ "name": cgi.escape(name),
+ "size": size,
+ "lastModified": lastModified,
+ "type": contentType,
+ }
)
+ output.append(
+ """</table></div>"""
+ """<div class="directory-listing">"""
+ """<h1>Properties</h1>"""
+ """<table>"""
+ """<tr><th>Name</th> <th>Value</th></tr>"""
+ )
+
def gotProperties(qnames):
ds = []
@@ -988,10 +986,9 @@
d = DeferredList(ds)
d.addCallback(gotValues)
return d
- d.addCallback(
- _gotChildren).addCallback(
- lambda _: self.listProperties(request)).addCallback(
- gotProperties)
+
+ d = self.listProperties(request)
+ d.addCallback(gotProperties)
return d
def getChildDirectoryEntry(self, child, name):
@@ -1119,7 +1116,6 @@
cache[property.qname()] = None
self.propertyStore.set(property)
cache[property.qname()] = property
- return succeed(None)
def contains(self, qname):
#self.log_debug("Contains: %r, %r" % (self.resource.fp.path, qname))
Modified: CalendarServer/trunk/twistedcaldav/freebusyurl.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/freebusyurl.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/freebusyurl.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -211,7 +211,7 @@
break
# Get inbox details
- inboxURL = yield principal.scheduleInboxURL(request)
+ inboxURL = principal.scheduleInboxURL()
if inboxURL is None:
raise HTTPError(StatusResponse(responsecode.INTERNAL_SERVER_ERROR, "No schedule inbox URL for principal: %s" % (principal,)))
try:
Modified: CalendarServer/trunk/twistedcaldav/icaldav.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/icaldav.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/icaldav.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -135,14 +135,14 @@
free-busy for this principal's calendar user.
"""
- def scheduleInboxURL(request=None):
+ def scheduleInboxURL():
"""
Get the schedule INBOX URL for this principal's calendar user.
- @return: a Deferred that fires with a string containing the URL from the schedule-inbox-URL property.
+ @return: a string containing the URL from the schedule-inbox-URL property.
"""
- def scheduleOutboxURL(request=None):
+ def scheduleOutboxURL():
"""
Get the schedule OUTBOX URL for this principal's calendar user.
- @return: a Deferred that fires with string containing the URL from the schedule-outbox-URL property.
+ @return: a string containing the URL from the schedule-outbox-URL property.
"""
Modified: CalendarServer/trunk/twistedcaldav/index.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/index.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/index.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -42,7 +42,7 @@
from vobject.icalendar import utc
-from twisted.internet.defer import maybeDeferred, succeed, returnValue
+from twisted.internet.defer import maybeDeferred, succeed
from twistedcaldav.ical import Component
from twistedcaldav.query import calendarquery
@@ -199,7 +199,7 @@
assert result is None, "More than one resource with UID %s in calendar collection %r" % (uid, self)
result = name
- return succeed(result)
+ return result
def resourceUIDForName(self, name):
"""
@@ -226,7 +226,7 @@
oldUID = self.resourceUIDForName(name)
if oldUID is not None:
self._delete_from_db(name, oldUID)
- self._add_to_db(name, calendar)
+ self._add_to_db(name, calendar, reCreate=reCreate)
if not fast:
self._db_commit()
@@ -321,16 +321,15 @@
rowiter = self._db_execute("select DISTINCT RESOURCE.NAME, RESOURCE.UID, RESOURCE.TYPE" + qualifiers[0], *qualifiers[1])
# Check result for missing resources
- rows = []
+
for row in rowiter:
name = row[0]
if self.resource.getChild(name.encode("utf-8")):
- rows.append(row)
+ yield row
else:
log.err("Calendar resource %s is missing from %s. Removing from index."
% (name, self.resource))
self.deleteResource(name)
- return succeed(rows)
def bruteForceSearch(self):
"""
@@ -341,17 +340,17 @@
rowiter = self._db_execute("select NAME, UID, TYPE from RESOURCE")
# Check result for missing resources:
- rows = []
+
for row in rowiter:
name = row[0]
if self.resource.getChild(name.encode("utf-8")):
- rows.append(row)
+ yield row
else:
log.err("Calendar resource %s is missing from %s. Removing from index."
% (name, self.resource))
self.deleteResource(name)
- return succeed(rows)
+
def _db_version(self):
"""
@return: the schema version assigned to this index.
@@ -485,12 +484,10 @@
Given a resource name, remove it from the database and re-add it
with a longer expansion.
"""
- d = self.resource.getChild(name).iCalendar()
- def _gotCalendar(calendar):
- self._add_to_db(name, calendar, expand_until=expand_until, reCreate=True)
- self._db_commit()
- return d.addCallback(_gotCalendar)
-
+ calendar = self.resource.getChild(name).iCalendar()
+ self._add_to_db(name, calendar, expand_until=expand_until, reCreate=True)
+ self._db_commit()
+
def _add_to_db(self, name, calendar, cursor = None, expand_until=None, reCreate=False):
"""
Records the given calendar resource in the index with the given name.
@@ -778,8 +775,8 @@
@return: True if the UID is not in the index and is not reserved,
False otherwise.
"""
- return self.resourceNameForUID(uid).addCallback(
- lambda rname: rname is None or rname in names)
+ rname = self.resourceNameForUID(uid)
+ return (rname is None or rname in names)
def _db_type(self):
"""
@@ -890,7 +887,7 @@
"""
# iTIP does not require unique UIDs
- return succeed(True)
+ return True
def _db_type(self):
"""
Modified: CalendarServer/trunk/twistedcaldav/log.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/log.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/log.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -166,7 +166,7 @@
Clears all log levels to the default.
"""
logLevelsByNamespace.clear()
- logLevelsByNamespace[None] = "info" # Default log level
+ logLevelsByNamespace[None] = "warn" # Default log level
logLevelsByNamespace = {}
clearLogLevels()
Modified: CalendarServer/trunk/twistedcaldav/memcacheprops.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/memcacheprops.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/memcacheprops.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -182,25 +182,23 @@
self.log_debug("Building cache for %s" % (self.collection,))
cache = {}
- ds = []
+
for childName in childNames:
- d = self.collection.getChild(childName)
- def _gotChild(child):
- if child is not None:
- propertyStore = child.deadProperties()
- props = {}
- for qname in propertyStore.list(cache=False):
- props[qname] = propertyStore.get(qname, cache=False)
+ child = self.collection.getChild(childName)
+ if child is None:
+ continue
- cache[child.fp.path] = props
- d.addCallback(_gotChild)
- ds.append(d)
- def _collectedChildren(_):
- self._storeCache(cache)
- return cache
- return DeferredList(ds).addCallback(_collectedChildren)
+ propertyStore = child.deadProperties()
+ props = {}
+ for qname in propertyStore.list(cache=False):
+ props[qname] = propertyStore.get(qname, cache=False)
+ cache[child.fp.path] = props
+ self._storeCache(cache)
+
+ return cache
+
def setProperty(self, child, property, delete=False):
propertyCache, key, childCache, token = self.childCache(child)
Modified: CalendarServer/trunk/twistedcaldav/method/delete_common.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/delete_common.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/method/delete_common.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -143,7 +143,7 @@
lock = None
if not self.internal_request:
# Get data we need for implicit scheduling
- calendar = yield delresource.iCalendar()
+ calendar = delresource.iCalendar()
scheduler = ImplicitScheduler()
do_implicit_action, _ignore = (yield scheduler.testImplicitSchedulingDELETE(self.request, delresource, calendar))
if do_implicit_action:
@@ -205,9 +205,8 @@
errors = ResponseQueue(deluri, "DELETE", responsecode.NO_CONTENT)
- children = yield delresource.listChildren()
+ for childname in delresource.listChildren():
- for childname in children:
childurl = joinURL(deluri, childname)
child = (yield self.request.locateChildResource(delresource, childname))
Modified: CalendarServer/trunk/twistedcaldav/method/get.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/get.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/method/get.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -20,7 +20,7 @@
__all__ = ["http_GET"]
-from twisted.internet.defer import inlineCallbacks, returnValue, succeed
+from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.web2.dav import davxml
from twisted.web2.http import HTTPError
from twisted.web2.http import Response
Modified: CalendarServer/trunk/twistedcaldav/method/propfind.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/propfind.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/method/propfind.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -24,10 +24,11 @@
"""
WebDAV PROPFIND method
"""
+
__all__ = ["http_PROPFIND"]
from twisted.python.failure import Failure
-from twisted.internet.defer import inlineCallbacks, returnValue, succeed
+from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.web2.http import HTTPError
from twisted.web2 import responsecode
from twisted.web2.http import StatusResponse
Modified: CalendarServer/trunk/twistedcaldav/method/put_common.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/put_common.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/method/put_common.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -116,7 +116,7 @@
self.destination_created = False
if self.destination_index_deleted:
# Must read in calendar for destination being re-indexed
- self.storer.destination.iCalendar().addCallback(self.storer.doDestinationIndex)
+ self.storer.doDestinationIndex(self.storer.destination.iCalendar())
self.destination_index_deleted = False
log.debug("Rollback: destination re-indexed %s" % (self.storer.destination.fp.path,))
if self.source_index_deleted:
@@ -313,7 +313,7 @@
raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "supported-calendar-data")))
# At this point we need the calendar data to do more tests
- self.calendar = yield self.source.iCalendar()
+ self.calendar = self.source.iCalendar()
else:
try:
if type(self.calendar) in (types.StringType, types.UnicodeType,):
@@ -357,7 +357,7 @@
# FIXME: We need this here because we have to re-index the destination. Ideally it
# would be better to copy the index entries from the source and add to the destination.
- self.calendar = yield self.source.iCalendar()
+ self.calendar = self.source.iCalendar()
# Check access
if self.destinationcal and config.EnablePrivateEvents:
@@ -368,7 +368,7 @@
elif self.sourcecal:
self.source_index = self.sourceparent.index()
- self.calendar = yield self.source.iCalendar()
+ self.calendar = self.source.iCalendar()
@inlineCallbacks
def validCopyMoveOperation(self):
@@ -573,7 +573,6 @@
return succeed(None)
- @inlineCallbacks
def noUIDConflict(self, uid):
"""
Check that the UID of the new calendar object conforms to the requirements of
@@ -596,7 +595,7 @@
# UID must be unique
index = self.destinationparent.index()
if not index.isAllowedUID(uid, oldname, self.destination.fp.basename()):
- rname = yield index.resourceNameForUID(uid)
+ rname = index.resourceNameForUID(uid)
# This can happen if two simultaneous PUTs occur with the same UID.
# i.e. one PUT has reserved the UID but has not yet written the resource,
# the other PUT tries to reserve and fails but no index entry exists yet.
@@ -614,7 +613,7 @@
result = False
message = "Cannot overwrite calendar resource %s with different UID %s" % (rname, olduid)
- returnValue((result, message, rname))
+ return result, message, rname
@inlineCallbacks
def checkQuota(self):
@@ -703,9 +702,11 @@
if old_has_private_comments and not new_has_private_comments:
# Transfer old comments to new calendar
log.debug("Private Comments properties were entirely removed by the client. Restoring existing properties.")
- self.destination.iCalendar().addCallback(self.calendar.transferProperties,
- "X-CALENDARSERVER-PRIVATE-COMMENT",
- "X-CALENDARSERVER-ATTENDEE-COMMENT")
+ old_calendar = self.destination.iCalendar()
+ self.calendar.transferProperties(old_calendar, (
+ "X-CALENDARSERVER-PRIVATE-COMMENT",
+ "X-CALENDARSERVER-ATTENDEE-COMMENT",
+ ))
self.calendardata = None
return new_has_private_comments
@@ -947,7 +948,7 @@
# UID conflict check - note we do this after reserving the UID to avoid a race condition where two requests
# try to write the same calendar data to two different resource URIs.
if not self.isiTIP:
- result, message, rname = yield self.noUIDConflict(self.uid)
+ result, message, rname = self.noUIDConflict(self.uid)
if not result:
log.err(message)
raise HTTPError(ErrorResponse(responsecode.FORBIDDEN,
Modified: CalendarServer/trunk/twistedcaldav/method/report_calquery.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/report_calquery.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/method/report_calquery.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -173,13 +173,11 @@
try:
# Get list of children that match the search and have read
# access
- results = yield calresource.index().indexedSearch(filter)
names = [name for name, ignore_uid, ignore_type
- in results]
+ in calresource.index().indexedSearch(filter)]
except IndexedSearchException:
- results = calresource.index().bruteForceSearch()
names = [name for name, ignore_uid, ignore_type
- in results]
+ in calresource.index().bruteForceSearch()]
index_query_ok = False
if not names:
@@ -202,7 +200,7 @@
child_path_name = urllib.unquote(child_uri_name)
if generate_calendar_data or not index_query_ok:
- calendar = yield calresource.iCalendar(child_path_name)
+ calendar = calresource.iCalendar(child_path_name)
assert calendar is not None, "Calendar %s is missing from calendar collection %r" % (child_uri_name, self)
else:
calendar = None
@@ -226,7 +224,7 @@
# Check private events access status
isowner = (yield calresource.isOwner(request, adminprincipals=True, readprincipals=True))
- calendar = yield calresource.iCalendar()
+ calendar = calresource.iCalendar()
yield queryCalendarObjectResource(calresource, uri, None, calendar, timezone)
returnValue(True)
Modified: CalendarServer/trunk/twistedcaldav/method/report_common.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/report_common.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/method/report_common.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -253,9 +253,9 @@
access = None
if calendar:
- propvalue = yield property.elementFromCalendarWithAccessRestrictions(calendar, access, timezone)
+ propvalue = property.elementFromCalendarWithAccessRestrictions(calendar, access, timezone)
else:
- propvalue = yield property.elementFromResourceWithAccessRestrictions(resource, access, timezone)
+ propvalue = property.elementFromResourceWithAccessRestrictions(resource, access, timezone)
if propvalue is None:
raise ValueError("Invalid CalDAV:calendar-data for request: %r" % (property,))
properties_by_status[responsecode.OK].append(propvalue)
@@ -352,9 +352,9 @@
filteredaces = (yield calresource.inheritedACEsforChildren(request))
try:
- resources = yield calresource.index().indexedSearch(filter, fbtype=True)
+ resources = calresource.index().indexedSearch(filter, fbtype=True)
except IndexedSearchException:
- resources = yield calresource.index().bruteForceSearch()
+ resources = calresource.index().bruteForceSearch()
# We care about separate instances for VEVENTs only
aggregated_resources = {}
@@ -367,6 +367,7 @@
# Check privileges - must have at least CalDAV:read-free-busy
child = (yield request.locateChildResource(calresource, name))
+
# TODO: for server-to-server we bypass this right now as we have no way to authorize external users.
if not servertoserver:
try:
@@ -417,7 +418,7 @@
fbinfo[fbtype_index_mapper.get(fbtype, 0)].append(clipped)
else:
- calendar = yield ncalresource.iCalendar(name)
+ calendar = calresource.iCalendar(name)
# The calendar may come back as None if the resource is being changed, or was deleted
# between our initial index query and getting here. For now we will ignore this error, but in
Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/resource.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -316,13 +316,13 @@
principal = (yield self.ownerPrincipal(request))
# Map owner to their inbox
- inboxURL = yield principal.scheduleInboxURL(request)
+ inboxURL = principal.scheduleInboxURL()
if inboxURL:
inbox = (yield request.locateResource(inboxURL))
myurl = (yield self.canonicalURL(request))
inbox.processFreeBusyCalendar(myurl, property.children[0] == caldavxml.Opaque())
- result = yield super(CalDAVResource, self).writeProperty(property, request)
+ result = (yield super(CalDAVResource, self).writeProperty(property, request))
returnValue(result)
def writeDeadProperty(self, property):
@@ -501,18 +501,18 @@
ca.addCallback(lambda ign: child)
return ca
- def gotChild(child, childpath, children):
+ def gotChild(child, childpath):
if child.isCalendarCollection():
callback(child, childpath)
elif child.isCollection():
if depth == "infinity":
fc = child.findCalendarCollections(depth, request, callback, privileges)
- fc.addCallback(lambda x: reactor.callLater(0, getChild, children))
+ fc.addCallback(lambda x: reactor.callLater(0, getChild))
return fc
- reactor.callLater(0, getChild, children)
+ reactor.callLater(0, getChild)
- def getChild(children):
+ def getChild():
try:
childname = children.pop()
except IndexError:
@@ -521,14 +521,15 @@
childpath = joinURL(basepath, childname)
child = request.locateResource(childpath)
child.addCallback(checkPrivileges)
- child.addCallbacks(gotChild, checkPrivilegesError, (childpath,), children)
+ child.addCallbacks(gotChild, checkPrivilegesError, (childpath,))
child.addErrback(completionDeferred.errback)
completionDeferred = Deferred()
if depth != "0" and self.isCollection():
basepath = request.urlForResource(self)
- self.listChildren().addCallback(getChild)
+ children = self.listChildren()
+ getChild()
else:
completionDeferred.callback(None)
@@ -552,10 +553,10 @@
"""
# For backwards compatibility we need to sync this up with the calendar-free-busy-set on the inbox
- principal = yield self.ownerPrincipal(request)
- inboxURL = yield principal.scheduleInboxURL(request)
+ principal = (yield self.ownerPrincipal(request))
+ inboxURL = principal.scheduleInboxURL()
if inboxURL:
- inbox = yield request.locateResource(inboxURL)
+ inbox = (yield request.locateResource(inboxURL))
inbox.processFreeBusyCalendar(request.path, False)
@inlineCallbacks
@@ -565,12 +566,12 @@
"""
# For backwards compatibility we need to sync this up with the calendar-free-busy-set on the inbox
- principal = yield self.ownerPrincipal(request)
- inboxURL = yield principal.scheduleInboxURL(request)
+ principal = (yield self.ownerPrincipal(request))
+ inboxURL = principal.scheduleInboxURL()
if inboxURL:
(_ignore_scheme, _ignore_host, destination_path, _ignore_query, _ignore_fragment) = urlsplit(normalizeURL(destination_uri))
- inbox = yield request.locateResource(inboxURL)
+ inbox = (yield request.locateResource(inboxURL))
inbox.processFreeBusyCalendar(request.path, False)
inbox.processFreeBusyCalendar(destination_uri, destination.isCalendarOpaque())
@@ -595,7 +596,7 @@
# Not allowed to delete the default calendar
principal = (yield self.ownerPrincipal(request))
- inboxURL = yield principal.scheduleInboxURL(request)
+ inboxURL = principal.scheduleInboxURL()
if inboxURL:
inbox = (yield request.locateResource(inboxURL))
default = (yield inbox.readProperty((caldav_namespace, "schedule-default-calendar-URL"), request))
@@ -617,18 +618,14 @@
an infinite loop. A subclass must override one of both of these
methods.
"""
- d = self.iCalendarText(name)
- def _gotData(calendar_data):
- if calendar_data is None:
- return None
+ calendar_data = self.iCalendarText(name)
- try:
- return iComponent.fromString(calendar_data)
- except ValueError:
- return None
+ if calendar_data is None: return None
- d.addCallback(_gotData)
- return d
+ try:
+ return iComponent.fromString(calendar_data)
+ except ValueError:
+ return None
def iCalendarRolledup(self, request):
"""
@@ -651,7 +648,7 @@
an infinite loop. A subclass must override one of both of these
methods.
"""
- return self.iCalendar(name).addCallback(str)
+ return str(self.iCalendar(name))
def iCalendarXML(self, name=None):
"""
@@ -659,7 +656,7 @@
This implementation returns an XML element constructed from the object
returned by L{iCalendar} when given the same arguments.
"""
- return self.iCalendar(name).addCallback(caldavxml.CalendarData.fromCalendar)
+ return caldavxml.CalendarData.fromCalendar(self.iCalendar(name))
def iCalendarAddressDoNormalization(self, ical):
"""
@@ -858,9 +855,8 @@
if namespace == caldav_namespace:
if name == "calendar-home-set":
- urls = yield self.calendarHomeURLs(request)
returnValue(caldavxml.CalendarHomeSet(
- *[davxml.HRef(url) for url in urls]
+ *[davxml.HRef(url) for url in self.calendarHomeURLs()]
))
elif name == "calendar-user-address-set":
@@ -869,14 +865,14 @@
))
elif name == "schedule-inbox-URL":
- url = yield self.scheduleInboxURL(request)
+ url = self.scheduleInboxURL()
if url is None:
returnValue(None)
else:
returnValue(caldavxml.ScheduleInboxURL(davxml.HRef(url)))
elif name == "schedule-outbox-URL":
- url = yield self.scheduleOutboxURL(request)
+ url = self.scheduleOutboxURL()
if url is None:
returnValue(None)
else:
@@ -961,38 +957,38 @@
d.addCallback(gotInbox)
return d
- def scheduleInbox(self, request=None):
+ def scheduleInbox(self, request):
"""
@return: the deferred schedule inbox for this principal.
"""
- return self.scheduleInboxURL(request).addCallback(request.locateResource)
+ return request.locateResource(self.scheduleInboxURL())
- def scheduleInboxURL(self, request=None):
+ def scheduleInboxURL(self):
if self.hasDeadProperty((caldav_namespace, "schedule-inbox-URL")):
inbox = self.readDeadProperty((caldav_namespace, "schedule-inbox-URL"))
- return succeed(str(inbox.children[0]))
+ return str(inbox.children[0])
else:
- return succeed(None)
+ return None
- def scheduleOutboxURL(self, request=None):
+ def scheduleOutboxURL(self):
"""
@return: the schedule outbox URL for this principal.
"""
if self.hasDeadProperty((caldav_namespace, "schedule-outbox-URL")):
outbox = self.readDeadProperty((caldav_namespace, "schedule-outbox-URL"))
- return succeed(str(outbox.children[0]))
+ return str(outbox.children[0])
else:
- return succeed(None)
+ return None
- def dropboxURL(self, request=None):
+ def dropboxURL(self):
"""
@return: the drop box home collection URL for this principal.
"""
if self.hasDeadProperty((calendarserver_namespace, "dropbox-home-URL")):
inbox = self.readDeadProperty((caldav_namespace, "dropbox-home-URL"))
- return succeed(str(inbox.children[0]))
+ return str(inbox.children[0])
else:
- return succeed(None)
+ return None
##
# Quota
Modified: CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/implicit.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/scheduling/implicit.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -69,8 +69,7 @@
self.internal_request = internal_request
existing_resource = resource.exists()
- schedulingObject = yield self.checkSchedulingObjectResource(resource)
- existing_type = "schedule" if schedulingObject else "calendar"
+ existing_type = "schedule" if self.checkSchedulingObjectResource(resource) else "calendar"
new_type = "schedule" if (yield self.checkImplicitState()) else "calendar"
if existing_type == "calendar":
@@ -87,7 +86,7 @@
# Also make sure that we return the new calendar being written rather than the old one
# when the implicit action is executed
self.return_calendar = calendar
- self.calendar = yield resource.iCalendar()
+ self.calendar = resource.iCalendar()
yield self.checkImplicitState()
# Attendees are not allowed to overwrite one type with another
@@ -107,9 +106,8 @@
new_type = "schedule" if (yield self.checkImplicitState()) else "calendar"
dest_exists = destresource.exists()
- dest_is_implicit = yield self.checkSchedulingObjectResource(destresource)
- src_is_implicit = yield self.checkSchedulingObjectResource(srcresource)
- src_is_implicit = src_is_implicit or new_type == "schedule"
+ dest_is_implicit = self.checkSchedulingObjectResource(destresource)
+ src_is_implicit = self.checkSchedulingObjectResource(srcresource) or new_type == "schedule"
if srccal and destcal:
if src_is_implicit and dest_exists or dest_is_implicit:
@@ -138,9 +136,8 @@
new_type = "schedule" if (yield self.checkImplicitState()) else "calendar"
- dest_is_implicit = yield self.checkSchedulingObjectResource(destresource)
- src_is_implicit = yield self.checkSchedulingObjectResource(srcresource)
- src_is_implicit = src_is_implicit or new_type == "schedule"
+ dest_is_implicit = self.checkSchedulingObjectResource(destresource)
+ src_is_implicit = self.checkSchedulingObjectResource(srcresource) or new_type == "schedule"
if srccal and destcal:
if src_is_implicit or dest_is_implicit:
@@ -168,13 +165,11 @@
yield self.checkImplicitState()
- schedulingObject = yield self.checkSchedulingObjectResource(resource)
- resource_type = "schedule" if schedulingObject else "calendar"
+ resource_type = "schedule" if self.checkSchedulingObjectResource(resource) else "calendar"
self.action = "remove" if resource_type == "schedule" else "none"
returnValue((self.action != "none", False,))
- @inlineCallbacks
def checkSchedulingObjectResource(self, resource):
if resource and resource.exists():
@@ -183,24 +178,24 @@
except HTTPError:
implicit = None
if implicit is not None:
- returnValue(implicit != "false")
+ return implicit != "false"
else:
- calendar = yield resource.iCalendar()
+ calendar = resource.iCalendar()
# Get the ORGANIZER and verify it is the same for all components
try:
organizer = calendar.validOrganizerForScheduling()
except ValueError:
# We have different ORGANIZERs in the same iCalendar object - this is an error
- returnValue(False)
+ return False
organizerPrincipal = resource.principalForCalendarUserAddress(organizer) if organizer else None
resource.writeDeadProperty(TwistedSchedulingObjectResource("true" if organizerPrincipal != None else "false"))
log.debug("Implicit - checked scheduling object resource state for UID: '%s', result: %s" % (
calendar.resourceUID(),
"true" if organizerPrincipal != None else "false",
))
- returnValue(organizerPrincipal != None)
+ return organizerPrincipal != None
- returnValue(False)
+ return False
@inlineCallbacks
def checkImplicitState(self):
@@ -372,7 +367,7 @@
# Get owner's calendar-home
calendar_owner_principal = (yield self.resource.ownerPrincipal(self.request))
- calendar_home = yield calendar_owner_principal.calendarHome(self.request)
+ calendar_home = calendar_owner_principal.calendarHome()
check_parent_uri = parentForURL(check_uri)[:-1] if check_uri else None
@@ -384,13 +379,12 @@
@inlineCallbacks
def queryCalendarCollection(collection, collection_uri):
- rname = yield collection.index().resourceNameForUID(self.uid)
+ rname = collection.index().resourceNameForUID(self.uid)
if rname:
child = (yield self.request.locateResource(joinURL(collection_uri, rname)))
if child == check_resource:
returnValue(True)
- schedulingObject = yield self.checkSchedulingObjectResource(child)
- matched_type = "schedule" if schedulingObject else "calendar"
+ matched_type = "schedule" if self.checkSchedulingObjectResource(child) else "calendar"
if (
collection_uri != check_parent_uri and
(type == "schedule" or matched_type == "schedule")
@@ -458,7 +452,7 @@
"""
# Find outbox
- outboxURL = yield principal.scheduleOutboxURL(self.request)
+ outboxURL = principal.scheduleOutboxURL()
outbox = (yield self.request.locateResource(outboxURL))
yield outbox.authorize(self.request, (caldavxml.ScheduleSend(),))
@@ -487,7 +481,7 @@
elif self.action == "modify":
# Read in existing data
- self.oldcalendar = yield self.resource.iCalendar()
+ self.oldcalendar = self.resource.iCalendar()
# Significant change
no_change, self.changed_rids, reinvites, recurrence_reschedule = self.isOrganizerChangeInsignificant()
Modified: CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -15,8 +15,9 @@
##
from twext.web2.dav.davxml import ErrorResponse
-from twisted.internet.defer import inlineCallbacks, returnValue, fail, succeed
+from twisted.internet.defer import inlineCallbacks, returnValue
+
from twisted.python.failure import Failure
from twisted.web2 import responsecode
@@ -487,7 +488,7 @@
else:
# Map recipient to their inbox
inbox = None
- inboxURL = yield principal.scheduleInboxURL()
+ inboxURL = principal.scheduleInboxURL()
if inboxURL:
inbox = (yield self.request.locateResource(inboxURL))
@@ -508,7 +509,7 @@
# Verify that the ORGANIZER's cu address maps to a valid user
organizer = self.calendar.getOrganizer()
if organizer:
- organizerPrincipal = yield self.resource.principalForCalendarUserAddress(organizer)
+ organizerPrincipal = self.resource.principalForCalendarUserAddress(organizer)
if organizerPrincipal:
outboxURL = organizerPrincipal.scheduleOutboxURL()
if outboxURL:
@@ -532,20 +533,16 @@
raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
def checkOrganizerAsOriginator(self):
- def _checkoutboxurl(outboxuri):
- if outboxuri != self.request.uri:
- log.err("Wrong outbox for ORGANIZER in calendar data: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
- return outboxuri
-
+
# Make sure that the ORGANIZER is local
if not isinstance(self.organizer, LocalCalendarUser):
log.err("ORGANIZER is not local to server in calendar data: %s" % (self.calendar,))
raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
# Make sure that the ORGANIZER's Outbox is the request URI
- if self.doingPOST:
- return self.organizer.principal.scheduleOutboxURL().addCallback(_checkoutboxurl)
+ if self.doingPOST and self.organizer.principal.scheduleOutboxURL() != self.request.uri:
+ log.err("Wrong outbox for ORGANIZER in calendar data: %s" % (self.calendar,))
+ raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
def checkAttendeeAsOriginator(self):
"""
@@ -559,23 +556,19 @@
# Must have only one
if len(attendees) != 1:
log.err("Wrong number of ATTENDEEs in calendar data: %s" % (self.calendar,))
- return fail(HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "attendee-allowed"))))
+ raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "attendee-allowed")))
attendee = attendees[0]
# Attendee's Outbox MUST be the request URI
attendeePrincipal = self.resource.principalForCalendarUserAddress(attendee)
- d = attendeePrincipal.scheduleOutboxURL(self.request)
- def _gotOutboxURL(outboxURL):
- if attendeePrincipal:
- if self.doingPOST and outboxURL != self.request.uri:
- log.err("ATTENDEE in calendar data does not match owner of Outbox: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "attendee-allowed")))
- else:
- log.err("Unknown ATTENDEE in calendar data: %s" % (self.calendar,))
+ if attendeePrincipal:
+ if self.doingPOST and attendeePrincipal.scheduleOutboxURL() != self.request.uri:
+ log.err("ATTENDEE in calendar data does not match owner of Outbox: %s" % (self.calendar,))
raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "attendee-allowed")))
+ else:
+ log.err("Unknown ATTENDEE in calendar data: %s" % (self.calendar,))
+ raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "attendee-allowed")))
- return d.addCallback(_gotOutboxURL)
-
def securityChecks(self):
"""
Check that the originator has the appropriate rights to send this type of iTIP message.
@@ -583,18 +576,15 @@
# Prevent spoofing of ORGANIZER with specific METHODs when local
if self.calendar.propertyValue("METHOD") in ("PUBLISH", "REQUEST", "ADD", "CANCEL", "DECLINECOUNTER"):
- return self.checkOrganizerAsOriginator()
+ self.checkOrganizerAsOriginator()
# Prevent spoofing when doing reply-like METHODs
elif self.calendar.propertyValue("METHOD") in ("REPLY", "COUNTER", "REFRESH"):
- return self.checkAttendeeAsOriginator()
+ self.checkAttendeeAsOriginator()
else:
log.err("Unknown iTIP METHOD for security checks: %s" % (self.calendar.propertyValue("METHOD"),))
- return fail(HTTPError(ErrorResponse(
- responsecode.FORBIDDEN,
- (caldav_namespace, "valid-calendar-data"),
- description="Unknown iTIP METHOD for security checks")))
+ raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description="Unknown iTIP METHOD for security checks"))
def finalChecks(self):
"""
@@ -710,7 +700,7 @@
else:
# Map recipient to their inbox
inbox = None
- inboxURL = yield principal.scheduleInboxURL()
+ inboxURL = principal.scheduleInboxURL()
if inboxURL:
inbox = (yield self.request.locateResource(inboxURL))
@@ -897,7 +887,7 @@
else:
# Map recipient to their inbox
inbox = None
- inboxURL = yield principal.scheduleInboxURL()
+ inboxURL = principal.scheduleInboxURL()
if inboxURL:
inbox = (yield self.request.locateResource(inboxURL))
Modified: CalendarServer/trunk/twistedcaldav/scheduling/utils.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/utils.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/scheduling/utils.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -37,7 +37,9 @@
request._rememberResource(calendar_home, calendar_home.url())
# Run a UID query against the UID
- def queryCalendarCollection(rname, collection, uri):
+
+ def queryCalendarCollection(collection, uri):
+ rname = collection.index().resourceNameForUID(uid)
if rname:
result["resource"] = collection.getChild(rname)
result["resource_name"] = rname
@@ -46,10 +48,9 @@
return succeed(False)
else:
return succeed(True)
- def getResourceName(collection, uri):
- return collection.index().resourceNameForUID(uid).addCallback(queryCalendarCollection, collection, uri)
+
# NB We are by-passing privilege checking here. That should be OK as the data found is not
# exposed to the user.
- yield report_common.applyToCalendarCollections(calendar_home, request, calendar_home.url(), "infinity", getResourceName, None)
+ yield report_common.applyToCalendarCollections(calendar_home, request, calendar_home.url(), "infinity", queryCalendarCollection, None)
returnValue((result["resource"], result["resource_name"], result["calendar_collection"], result["calendar_collection_uri"],))
Modified: CalendarServer/trunk/twistedcaldav/static.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/static.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/static.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -34,15 +34,14 @@
"TimezoneServiceFile",
]
+import datetime
import os
-import datetime
import errno
from urlparse import urlsplit
from twext.web2.dav.davxml import ErrorResponse
-from twisted.internet.defer import (fail, succeed, inlineCallbacks, returnValue,
- maybeDeferred, Deferred)
+from twisted.internet.defer import fail, succeed, inlineCallbacks, returnValue, maybeDeferred
from twisted.python.failure import Failure
from twisted.web2 import responsecode, http, http_headers
from twisted.web2.http import HTTPError, StatusResponse
@@ -87,15 +86,6 @@
"""
CalDAV-accessible L{DAVFile} resource.
"""
- propertyStore = CachingPropertyStore
-
- @classmethod
- def fetch(cls, request, path, *args, **kwargs):
- """
- stuff etc
- """
- return succeed(cls(path, *args, **kwargs))
-
def __repr__(self):
if self.isCalendarCollection():
return "<%s (calendar collection): %s>" % (self.__class__.__name__, self.fp.path)
@@ -284,7 +274,7 @@
continue
# Get the access filtered view of the data
- caldata = yield child.iCalendarTextFiltered(isowner)
+ caldata = child.iCalendarTextFiltered(isowner)
try:
subcalendar = iComponent.fromString(caldata)
except ValueError:
@@ -324,7 +314,7 @@
def iCalendarText(self, name=None):
if self.isPseudoCalendarCollection():
if name is None:
- return self.iCalendar().addCallback(str)
+ return str(self.iCalendar())
try:
calendar_file = self.fp.child(name).open()
@@ -333,7 +323,7 @@
raise
elif self.isCollection():
- return succeed(None)
+ return None
else:
if name is not None:
@@ -347,10 +337,10 @@
finally:
calendar_file.close()
- return succeed(calendar_data)
+ return calendar_data
def iCalendarXML(self, name=None):
- return self.iCalendarText(name).addCallback(caldavxml.CalendarData.fromCalendar)
+ return caldavxml.CalendarData.fromCalendar(self.iCalendarText(name))
def supportedPrivileges(self, request):
# read-free-busy support on calendar collection and calendar object resources
@@ -387,9 +377,10 @@
##
def listChildren(self):
- return super(CalDAVFile, self).listChildren().addCallback(
- lambda children: [child for child in children
- if not child.startswith(".")])
+ return [
+ child for child in super(CalDAVFile, self).listChildren()
+ if not child.startswith(".")
+ ]
def propertyCollection(self):
if not hasattr(self, "_propertyCollection"):
@@ -398,34 +389,48 @@
def createSimilarFile(self, path):
if path == self.fp.path:
- return succeed(self)
+ return self
- d = super(CalDAVFile, self).createSimilarFile(path)
- def _gotFile(similar):
- if isCalendarCollectionResource(self):
- #
- # Override DELETE, MOVE
- #
- for method in ("DELETE", "MOVE"):
- method = "http_" + method
- original = getattr(similar, method)
+ similar = super(CalDAVFile, self).createSimilarFile(path)
- @inlineCallbacks
- def override(request, original=original):
+ if isCalendarCollectionResource(self):
+ #
+ # Override the dead property store
+ #
+ superDeadProperties = similar.deadProperties
- # Call original method (which is deferred)
- response = (yield original(request))
+ def deadProperties():
+ if not hasattr(similar, "_dead_properties"):
+ similar._dead_properties = self.propertyCollection().propertyStoreForChild(
+ similar,
+ superDeadProperties(caching=False)
+ )
+ return similar._dead_properties
- # Wipe the cache
- similar.deadProperties().flushCache()
+ similar.deadProperties = deadProperties
- returnValue(response)
+ #
+ # Override DELETE, MOVE
+ #
+ for method in ("DELETE", "MOVE"):
+ method = "http_" + method
+ original = getattr(similar, method)
- setattr(similar, method, override)
+ @inlineCallbacks
+ def override(request, original=original):
- return similar
- return d.addCallback(_gotFile)
+ # Call original method (which is deferred)
+ response = (yield original(request))
+ # Wipe the cache
+ similar.deadProperties().flushCache()
+
+ returnValue(response)
+
+ setattr(similar, method, override)
+
+ return similar
+
def updateCTag(self):
assert self.isCollection()
try:
@@ -549,20 +554,21 @@
class AutoProvisioningFileMixIn (AutoProvisioningResourceMixIn):
def provision(self):
- d = self.provisionFile()
- super(AutoProvisioningFileMixIn, self).provision()
- return d
+ self.provisionFile()
+ return super(AutoProvisioningFileMixIn, self).provision()
- def provisionFile(self, request=None):
+
+ def provisionFile(self):
if hasattr(self, "_provisioned_file"):
- return succeed(False)
+ return False
else:
self._provisioned_file = True
fp = self.fp
+
fp.restat(False)
if fp.exists():
- return succeed(False)
+ return False
log.msg("Provisioning file: %s" % (self,))
@@ -587,7 +593,7 @@
fp.open("w").close()
fp.restat(False)
- return succeed(True)
+ return True
class CalendarHomeProvisioningFile (AutoProvisioningFileMixIn, DirectoryCalendarHomeProvisioningResource, DAVFile):
"""
@@ -647,57 +653,56 @@
assert len(name) > 4, "Directory record has an invalid GUID: %r" % (name,)
childPath = self.fp.child(name[0:2]).child(name[2:4]).child(name)
- d = self.homeResourceClass.fetch(None, childPath.path, self, record)
- def _gotChild(child):
- if not child.exists():
- self.provision()
+ child = self.homeResourceClass(childPath.path, self, record)
- if not childPath.parent().isdir():
- childPath.parent().makedirs()
+ if not child.exists():
+ self.provision()
- for oldPath in (
- # Pre 2.0: All in one directory
- self.fp.child(name),
- # Pre 1.2: In types hierarchy instead of the GUID hierarchy
- self.parent.getChild(record.recordType).fp.child(record.shortNames[0]),
- ):
- if oldPath.exists():
- # The child exists at an old location. Move to new location.
- log.msg("Moving calendar home from old location %r to new location %r." % (oldPath, childPath))
- try:
- oldPath.moveTo(childPath)
- except (OSError, IOError), e:
- log.err("Error moving calendar home %r: %s" % (oldPath, e))
- raise HTTPError(StatusResponse(
- responsecode.INTERNAL_SERVER_ERROR,
- "Unable to move calendar home."
- ))
- child.fp.restat(False)
- break
- else:
- #
- # NOTE: provisionDefaultCalendars() returns a deferred, which we are ignoring.
- # The result being that the default calendars will be present at some point
- # in the future, not necessarily right now, and we don't have a way to wait
- # on that to finish.
- #
- child.provisionDefaultCalendars()
+ if not childPath.parent().isdir():
+ childPath.parent().makedirs()
- #
- # Try to work around the above a little by telling the client that something
- # when wrong temporarily if the child isn't provisioned right away.
- #
- if not child.exists():
+ for oldPath in (
+ # Pre 2.0: All in one directory
+ self.fp.child(name),
+ # Pre 1.2: In types hierarchy instead of the GUID hierarchy
+ self.parent.getChild(record.recordType).fp.child(record.shortNames[0]),
+ ):
+ if oldPath.exists():
+ # The child exists at an old location. Move to new location.
+ log.msg("Moving calendar home from old location %r to new location %r." % (oldPath, childPath))
+ try:
+ oldPath.moveTo(childPath)
+ except (OSError, IOError), e:
+ log.err("Error moving calendar home %r: %s" % (oldPath, e))
raise HTTPError(StatusResponse(
- responsecode.SERVICE_UNAVAILABLE,
- "Provisioning calendar home."
+ responsecode.INTERNAL_SERVER_ERROR,
+ "Unable to move calendar home."
))
+ child.fp.restat(False)
+ break
+ else:
+ #
+ # NOTE: provisionDefaultCalendars() returns a deferred, which we are ignoring.
+ # The result being that the default calendars will be present at some point
+ # in the future, not necessarily right now, and we don't have a way to wait
+ # on that to finish.
+ #
+ child.provisionDefaultCalendars()
- assert child.exists()
+ #
+ # Try to work around the above a little by telling the client that something
+ # when wrong temporarily if the child isn't provisioned right away.
+ #
+ if not child.exists():
+ raise HTTPError(StatusResponse(
+ responsecode.SERVICE_UNAVAILABLE,
+ "Provisioning calendar home."
+ ))
- return child
- return d.addCallback(_gotChild)
+ assert child.exists()
+ return child
+
def createSimilarFile(self, path):
raise HTTPError(responsecode.NOT_FOUND)
@@ -741,26 +746,21 @@
}.get(name, None)
if cls is not None:
- d = cls.fetch(None, self.fp.child(name).path, self)
- def _gotChild(child):
- child.cacheNotifier = self.cacheNotifier
- child.clientNotifier = self.clientNotifier
- return child
- return d.addCallback(_gotChild)
+ child = cls(self.fp.child(name).path, self)
+ child.cacheNotifier = self.cacheNotifier
+ child.clientNotifier = self.clientNotifier
+ return child
return self.createSimilarFile(self.fp.child(name).path)
-
def createSimilarFile(self, path):
if path == self.fp.path:
return self
else:
- d = CalDAVFile.fetch(None, path, principalCollections=self.principalCollections())
- def _gotChild(similar):
- similar.cacheNotifier = self.cacheNotifier
- similar.clientNotifier = self.clientNotifier
- return similar
- return d.addCallback(_gotChild)
+ similar = CalDAVFile(path, principalCollections=self.principalCollections())
+ similar.cacheNotifier = self.cacheNotifier
+ similar.clientNotifier = self.clientNotifier
+ return similar
def getChild(self, name):
# This avoids finding case variants of put children on case-insensitive filesystems.
Modified: CalendarServer/trunk/twistedcaldav/test/test_collectioncontents.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_collectioncontents.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/test/test_collectioncontents.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -192,11 +192,9 @@
fd.close()
fd = open(os.path.join(colpath, "bogus"), "w")
fd.close()
- d = self.site.resource.listChildren()
- def _gotChildren(children):
- self.assertTrue("bogus" in children)
- self.assertFalse("._bogus" in children)
- return d.addCallback(_gotChildren)
+ children = self.site.resource.listChildren()
+ self.assertTrue("bogus" in children)
+ self.assertFalse("._bogus" in children)
def test_fail_dot_file_put_in_calendar(self):
"""
Modified: CalendarServer/trunk/twistedcaldav/test/test_memcacheprops.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_memcacheprops.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/test/test_memcacheprops.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -27,7 +27,6 @@
import os
from twisted.web2.http import HTTPError
-from twisted.internet.defer import succeed
from twistedcaldav.memcacheprops import MemcachePropertyCollection
from twistedcaldav.test.util import InMemoryPropertyStore
@@ -49,7 +48,7 @@
return self.children.iterkeys()
def getChild(self, childName):
- return succeed(self.children[childName])
+ return self.children[childName]
def propertyCollection(self):
if not hasattr(self, "_propertyCollection"):
Modified: CalendarServer/trunk/twistedcaldav/test/test_sql.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_sql.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/test/test_sql.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -182,11 +182,9 @@
fd.close()
fd = open(os.path.join(colpath, "test"), "w")
fd.close()
- d = self.site.resource.listChildren()
- def _gotChildren(children):
- self.assertTrue("test" in children)
- self.assertFalse(db_prefix + "sqlite" in children)
- return d.addCallback(_gotChildren)
+ children = self.site.resource.listChildren()
+ self.assertTrue("test" in children)
+ self.assertFalse(db_prefix + "sqlite" in children)
def test_duplicate_create(self):
dbname = self.mktemp()
Modified: CalendarServer/trunk/twistedcaldav/test/test_static.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_static.py 2009-08-06 18:51:47 UTC (rev 4485)
+++ CalendarServer/trunk/twistedcaldav/test/test_static.py 2009-08-06 20:56:48 UTC (rev 4486)
@@ -38,10 +38,8 @@
def test_childrenHaveCacheNotifier(self):
- d = self.calendarHome.createSimilarFile('/fake/path')
- def _gotResource(child):
- self.assertEquals(child.cacheNotifier, self.calendarHome.cacheNotifier)
- return d.addCallback(_gotResource)
+ child = self.calendarHome.createSimilarFile('/fake/path')
+ self.assertEquals(child.cacheNotifier, self.calendarHome.cacheNotifier)
class CalDAVFileTests(TestCase):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090806/67d3098d/attachment-0001.html>
More information about the calendarserver-changes
mailing list