[CalendarServer-changes] [607]
CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/
directory
source_changes at macosforge.org
source_changes at macosforge.org
Mon Nov 27 19:05:19 PST 2006
Revision: 607
http://trac.macosforge.org/projects/calendarserver/changeset/607
Author: wsanchez at apple.com
Date: 2006-11-27 19:05:19 -0800 (Mon, 27 Nov 2006)
Log Message:
-----------
Undo most of r528 since there was no explanation as to what was broken.
- DirectoryPrincipalProvisioningResource is a principal collection
and should advertise and support all of the functionality thereof.
- I'd like to avoid having any of these resources implement
CalDAVFile, since we shouldn't need the calendar creation logic,
etc. in the principals hierarchy.
- We want to limit the result of principalCollections() to this
hierarchy, and not return all possible principal collections opn
the server. This hierachy only supports principals contained
within itself, not other principals which may also reside on the
server.
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/principal.py
CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/test/test_principal.py
Modified: CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/principal.py 2006-11-28 02:58:13 UTC (rev 606)
+++ CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/principal.py 2006-11-28 03:05:19 UTC (rev 607)
@@ -44,7 +44,7 @@
# FIXME: These should not be tied to DAVFile
-class DirectoryPrincipalProvisioningResource (ReadOnlyResourceMixIn, CalDAVFile):
+class DirectoryPrincipalProvisioningResource (ReadOnlyResourceMixIn, CalendarPrincipalCollectionResource, DAVFile):
"""
Collection resource which provisions directory principals as its children.
"""
@@ -56,9 +56,9 @@
"""
assert url.endswith("/"), "Collection URL must end in '/'"
- CalDAVFile.__init__(self, path)
+ CalendarPrincipalCollectionResource.__init__(self, url)
+ DAVFile.__init__(self, path)
- self._url = url
self.directory = IDirectoryService(directory)
# FIXME: Smells like a hack
@@ -99,8 +99,8 @@
return None
return typeResource.getChild(record.shortName)
- def collectionURL(self):
- return self._url
+ def principalCollections(self, request):
+ return succeed((self.principalCollectionURL(),))
##
# ACL
@@ -126,7 +126,7 @@
@param directory: an L{IDirectoryService} to provision calendars from.
@param recordType: the directory record type to provision.
"""
- CalendarPrincipalCollectionResource.__init__(self, joinURL(parent.collectionURL(), recordType) + "/")
+ CalendarPrincipalCollectionResource.__init__(self, joinURL(parent.principalCollectionURL(), recordType) + "/")
DAVFile.__init__(self, path)
self.directory = parent.directory
@@ -165,6 +165,12 @@
def principalForUser(self, user):
return self._parent.principalForUser(user)
+ def principalForRecord(self, record):
+ return self._parent.principalForRecord(record)
+
+ def principalCollections(self, request):
+ return self._parent.principalCollections(request)
+
##
# ACL
##
@@ -282,6 +288,9 @@
def groupMemberships(self):
return self._getRelatives("groups")
+ def principalCollections(self, request):
+ return self._parent.principalCollections(request)
+
##
# CalDAV
##
Modified: CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/test/test_principal.py
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/test/test_principal.py 2006-11-28 02:58:13 UTC (rev 606)
+++ CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/test/test_principal.py 2006-11-28 03:05:19 UTC (rev 607)
@@ -66,12 +66,15 @@
def test_hierarchy(self):
"""
- listChildren(), getChildren()
+ listChildren(), getChildren(), principalCollectionURL()
"""
for directory in directoryServices:
#print "\n -> %s" % (directory.__class__.__name__,)
provisioningResource = self.principalRootResources[directory.__class__.__name__]
+ provisioningURL = "/" + directory.__class__.__name__ + "/"
+ self.assertEquals(provisioningURL, provisioningResource.principalCollectionURL())
+
recordTypes = set(provisioningResource.listChildren())
self.assertEquals(recordTypes, set(directory.recordTypes()))
@@ -80,6 +83,9 @@
typeResource = provisioningResource.getChild(recordType)
self.failUnless(isinstance(typeResource, DirectoryPrincipalTypeResource))
+ typeURL = provisioningURL + recordType + "/"
+ self.assertEquals(typeURL, typeResource.principalCollectionURL())
+
shortNames = set(typeResource.listChildren())
self.assertEquals(shortNames, set(r.shortName for r in directory.listRecords(recordType)))
@@ -87,3 +93,6 @@
#print " -> %s" % (shortName,)
recordResource = typeResource.getChild(shortName)
self.failUnless(isinstance(recordResource, DirectoryPrincipalResource))
+
+ recordURL = typeURL + shortName
+ self.assertEquals(recordURL, recordResource.principalURL())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061127/a1c53439/attachment.html
More information about the calendarserver-changes
mailing list