[CalendarServer-changes] [670] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Dec 4 22:46:36 PST 2006
Revision: 670
http://trac.macosforge.org/projects/calendarserver/changeset/670
Author: wsanchez at apple.com
Date: 2006-12-04 22:46:35 -0800 (Mon, 04 Dec 2006)
Log Message:
-----------
More cleanup:
- Implement a coupdl of lookup methods in DirectoryPrincipalResource,
where we can do the job better than CalendarPrincipalResource
could.
- Drop box collection names don't really need to be configurable;
remove from default plists.
- Same with DropBoxInheritedACLs. The default needs to be right;
don't want to support alternate configs.
- Fix speling of DropBox.notifcationName.
- Don't need matchesCalendarUserAddress().
Modified Paths:
--------------
CalendarServer/trunk/conf/caldavd-test.plist
CalendarServer/trunk/conf/caldavd.plist
CalendarServer/trunk/twistedcaldav/directory/principal.py
CalendarServer/trunk/twistedcaldav/dropbox.py
CalendarServer/trunk/twistedcaldav/repository.py
CalendarServer/trunk/twistedcaldav/resource.py
CalendarServer/trunk/twistedcaldav/static.py
Modified: CalendarServer/trunk/conf/caldavd-test.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-test.plist 2006-12-05 05:32:15 UTC (rev 669)
+++ CalendarServer/trunk/conf/caldavd-test.plist 2006-12-05 06:46:35 UTC (rev 670)
@@ -153,18 +153,9 @@
<key>DropBoxEnabled</key>
<true/>
- <key>DropBoxName</key>
- <string>dropbox</string>
-
- <key>DropBoxInheritedACLs</key>
- <true/>
-
<key>NotificationsEnabled</key>
<true/>
- <key>NotificationCollectionName</key>
- <string>notifications</string>
-
<key>Repository</key>
<string>conf/repository.xml</string>
Modified: CalendarServer/trunk/conf/caldavd.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd.plist 2006-12-05 05:32:15 UTC (rev 669)
+++ CalendarServer/trunk/conf/caldavd.plist 2006-12-05 06:46:35 UTC (rev 670)
@@ -102,18 +102,9 @@
<key>DropBoxEnabled</key>
<true/>
- <key>DropBoxName</key>
- <string>dropbox</string>
-
- <key>DropBoxInheritedACLs</key>
- <true/>
-
<key>NotificationsEnabled</key>
<true/>
- <key>NotificationCollectionName</key>
- <string>notifications</string>
-
<key>Repository</key>
<string>/etc/caldavd/repository.xml</string>
Modified: CalendarServer/trunk/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/principal.py 2006-12-05 05:32:15 UTC (rev 669)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py 2006-12-05 06:46:35 UTC (rev 670)
@@ -38,6 +38,7 @@
from twistedcaldav.extensions import ReadOnlyResourceMixIn, DAVFile
from twistedcaldav.resource import CalendarPrincipalCollectionResource, CalendarPrincipalResource
from twistedcaldav.static import provisionFile
+from twistedcaldav.dropbox import Dropbox
from twistedcaldav.directory.idirectory import IDirectoryService
# FIXME: These should not be tied to DAVFile
@@ -304,14 +305,23 @@
# the directory record provides.
return (self.principalURL(),) + tuple(self.record.calendarUserAddresses)
+ def scheduleInbox(self):
+ home = self._calendarHome()
+ if home is None:
+ return succeed(None)
+
+ inbox = home.getChild("inbox")
+ if inbox is None:
+ return succeed(None)
+
+ return succeed(inbox)
+
def calendarHomeURLs(self):
- # FIXME: self.record.service.calendarHomesCollection smells like a hack
- # See CalendarHomeProvisioningFile.__init__()
- service = self.record.service
- if hasattr(service, "calendarHomesCollection"):
- return (service.calendarHomesCollection.homeForDirectoryRecord(self.record).url(),)
+ home = self._calendarHome()
+ if home is None:
+ return ()
else:
- return ()
+ return (home.url(),)
def scheduleInboxURL(self):
return self._homeChildURL("inbox/")
@@ -319,11 +329,26 @@
def scheduleOutboxURL(self):
return self._homeChildURL("outbox/")
+ def dropboxURL(self):
+ return self._homeChildURL(Dropbox.dropboxName + "/")
+
+ def notificationsURL(self):
+ return self._homeChildURL(Dropbox.notificationName + "/")
+
def _homeChildURL(self, name):
- homes = self.calendarHomeURLs()
- if homes:
- return joinURL(homes[0], name)
+ 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
+ # See CalendarHomeProvisioningFile.__init__()
+ service = self.record.service
+ if hasattr(service, "calendarHomesCollection"):
+ return service.calendarHomesCollection.homeForDirectoryRecord(self.record)
+ else:
return None
##
Modified: CalendarServer/trunk/twistedcaldav/dropbox.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/dropbox.py 2006-12-05 05:32:15 UTC (rev 669)
+++ CalendarServer/trunk/twistedcaldav/dropbox.py 2006-12-05 06:46:35 UTC (rev 670)
@@ -39,7 +39,7 @@
# inherited by child resources.
notifications = True # Whether to post notification messages into per-user notification collection.
- notifcationName = "notify" # Name of the collection in which notifications will be stored.
+ notificationName = "notify" # Name of the collection in which notifications will be stored.
@classmethod
def enable(clzz, enabled, dropboxName=None, inheritedACLs=None, notifications=None, notificationName=None):
@@ -61,7 +61,7 @@
if notifications:
DropBox.notifications = notifications
if notificationName:
- DropBox.notifcationName = notificationName
+ DropBox.notificationName = notificationName
if DropBox.enabled:
@@ -102,7 +102,7 @@
if not DropBox.notifications:
return
- child = CalDAVFile(os.path.join(cuhome.fp.path, DropBox.notifcationName))
+ child = CalDAVFile(os.path.join(cuhome.fp.path, DropBox.notificationName))
child_exists = child.exists()
if not child_exists:
c = child.createSpecialCollection(davxml.ResourceType.notifications)
Modified: CalendarServer/trunk/twistedcaldav/repository.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/repository.py 2006-12-05 05:32:15 UTC (rev 669)
+++ CalendarServer/trunk/twistedcaldav/repository.py 2006-12-05 06:46:35 UTC (rev 670)
@@ -127,7 +127,7 @@
quota, serverlogfile,
directoryservice,
dropbox, dropboxName, dropboxACLs,
- notifications, notifcationName,
+ notifications, notificationName,
manhole):
"""
Start the server using XML-based configuration details and supplied .plist based options.
@@ -174,7 +174,7 @@
self.logObserver.stop()
# Turn on drop box support before building the repository
- DropBox.enable(dropbox, dropboxName, dropboxACLs, notifications, notifcationName)
+ DropBox.enable(dropbox, dropboxName, dropboxACLs, notifications, notificationName)
dirname = directoryservice["type"]
dirparams = directoryservice["params"]
Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py 2006-12-05 05:32:15 UTC (rev 669)
+++ CalendarServer/trunk/twistedcaldav/resource.py 2006-12-05 06:46:35 UTC (rev 670)
@@ -55,11 +55,12 @@
import twistedcaldav
from twistedcaldav import caldavxml, customxml
+from twistedcaldav.extensions import DAVResource
from twistedcaldav.icaldav import ICalDAVResource, ICalendarPrincipalResource, ICalendarSchedulingCollectionResource
from twistedcaldav.caldavxml import caldav_namespace
from twistedcaldav.customxml import apple_namespace
from twistedcaldav.ical import Component as iComponent
-from twistedcaldav.extensions import DAVResource
+from twistedcaldav.dropbox import Dropbox
if twistedcaldav.__version__:
serverVersion = twisted.web2.server.VERSION + " TwistedCalDAV/" + twistedcaldav.__version__
@@ -463,7 +464,6 @@
"""
# Do this only for regular calendar collections and Inbox/Outbox
- from twistedcaldav.dropbox import DropBox
if self.isPseudoCalendarCollection() or \
DropBox.enabled and self.isSpecialCollection(customxml.DropBox):
# Add inheritable option to each ACE in the list
@@ -560,7 +560,7 @@
child = child.getResult()
if not isinstance(child, CalendarPrincipalResource):
continue
- if child.matchesCalendarUserAddress(request, address):
+ if address in child.calendarUserAddresses():
yield child
return
@@ -695,21 +695,13 @@
return maybeDeferred(defer)
def calendarHomeURLs(self):
- """
- See L{ICalendarPrincipalResource.calendarHomeURLs}.
- This implementation raises L{NotImplementedError} if the dead property
- C{(caldav_namespace, "calendar-home-set")} is not set.
- """
if self.hasDeadProperty((caldav_namespace, "calendar-home-set")):
home_set = self.readDeadProperty((caldav_namespace, "calendar-home-set"))
return [str(h) for h in home_set.children]
else:
- raise NotImplementedError()
+ return ()
def calendarUserAddresses(self):
- """
- See L{ICalendarPrincipalResource.calendarUserAddresses}.
- """
if self.hasDeadProperty((caldav_namespace, "calendar-user-address-set")):
addresses = self.readDeadProperty((caldav_namespace, "calendar-user-address-set"))
return [str(h) for h in addresses.children]
@@ -717,37 +709,39 @@
# Must have a valid address of some kind so use the principal uri
return (self.principalURL(),)
- @deferredGenerator
def calendarFreeBusyURIs(self, request):
- """
- See L{ICalendarPrincipalResource.calendarFreeBusyURIs}.
- """
- inbox = waitForDeferred(maybeDeferred(request.locateResource, self.scheduleInboxURL()))
- yield inbox
- inbox = inbox.getResult()
+ def gotInbox(inbox):
+ if inbox is None:
+ return ()
- if inbox is None:
- yield ()
- return
+ d = inbox.hasProperty((caldav_namespace, "calendar-free-busy-set"), request)
+ d.addCallback(getFreeBusy)
+ return d
- has = waitForDeferred(inbox.hasProperty((caldav_namespace, "calendar-free-busy-set"), request))
- yield has
- has = has.getResult()
-
- if not has:
- yield ()
- return
+ def getFreeBusy(has):
+ if not has:
+ return ()
- fbset = waitForDeferred(inbox.readProperty((caldav_namespace, "calendar-free-busy-set"), request))
- yield fbset
- fbset = fbset.getResult()
+ d = inbox.readProperty((caldav_namespace, "calendar-free-busy-set"), request)
+ d.addCallback(parseFreeBusy)
+ return d
- yield [str(h) for h in fbset.children]
+ def parseFreeBusy(freeBusySet):
+ return (str(href) for href in freeBusySet.children)
- def scheduleInboxURL(self):
+ d = self.scheduleInbox()
+ d.addCallback(gotInbox)
+ return d
+
+ def scheduleInbox(self):
"""
- @return: the schedule INBOX URL for this principal.
+ @return: the deferred schedule inbox for this principal.
"""
+ d = request.locateResource(self.scheduleInboxURL())
+ d.addCallback(gotInbox)
+ return d
+
+ def scheduleInboxURL(self):
if self.hasDeadProperty((caldav_namespace, "schedule-inbox-URL")):
inbox = self.readDeadProperty((caldav_namespace, "schedule-inbox-URL"))
return str(inbox.children[0])
@@ -756,7 +750,7 @@
def scheduleOutboxURL(self):
"""
- @return: the schedule OUTBOX URL for this principal.
+ @return: the schedule outbox URL for this principal.
"""
if self.hasDeadProperty((caldav_namespace, "schedule-outbox-URL")):
outbox = self.readDeadProperty((caldav_namespace, "schedule-outbox-URL"))
@@ -769,51 +763,19 @@
@return: the drop box home collection URL for this principal.
"""
# Use the first calendar home only
- from twistedcaldav.dropbox import DropBox
- url = None
for home in self.calendarHomeURLs():
- url = joinURL(home, DropBox.dropboxName) + "/"
- break
- return url
+ return joinURL(home, Dropbox.dropboxName)
+ return None
def notificationsURL(self):
"""
@return: the notifications collection URL for this principal.
"""
# Use the first calendar home only
- from twistedcaldav.dropbox import DropBox
- url = None
for home in self.calendarHomeURLs():
- url = joinURL(home, DropBox.notifcationName) + "/"
- break
- return url
+ return joinURL(home, Dropbox.notificationName)
+ return None
- def matchesCalendarUserAddress(self, request, address):
- """
- Determine whether this principal matches the supplied calendar user
- address.
- @param address: the calendar user address to match.
- @return: C{True} if the principal matches, C{False} otherwise.
- """
- # By default we will always allow either a relative or absolute URI to the principal to
- # be supplied as a valid calendar user address.
-
- # Try relative URI
- if self._url == address:
- return True
-
- # Try absolute URI
- absurl = request.unparseURL(path=self._url)
- if absurl == address:
- return True
-
- # Look at the property if URI lookup does not work
- for cua in self.calendarUserAddresses():
- if cua == address:
- return True
-
- return False
-
class CalendarSchedulingCollectionResource (CalDAVResource):
"""
CalDAV principal resource.
Modified: CalendarServer/trunk/twistedcaldav/static.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/static.py 2006-12-05 05:32:15 UTC (rev 669)
+++ CalendarServer/trunk/twistedcaldav/static.py 2006-12-05 06:46:35 UTC (rev 670)
@@ -54,6 +54,7 @@
from twistedcaldav.resource import ScheduleInboxResource, ScheduleOutboxResource
from twistedcaldav.resource import isCalendarCollectionResource
from twistedcaldav.extensions import DAVFile
+from twistedcaldav.dropbox import Dropbox
from twistedcaldav.directory.idirectory import IDirectoryService
class CalDAVFile (CalDAVResource, DAVFile):
@@ -625,7 +626,6 @@
# FIXME: This should provision itself also
# Provision a drop box
if self.record.recordType == "user":
- from twistedcaldav.dropbox import DropBox
DropBox.provision(self)
return d
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061204/fe0d12b3/attachment.html
More information about the calendarserver-changes
mailing list