[CalendarServer-changes] [633]
CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Fri Dec 1 10:17:42 PST 2006
Revision: 633
http://trac.macosforge.org/projects/calendarserver/changeset/633
Author: wsanchez at apple.com
Date: 2006-12-01 10:17:41 -0800 (Fri, 01 Dec 2006)
Log Message:
-----------
Nix CalendarPrincipalFile.
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/principal.py
CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/test/test_principal.py
CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/repository.py
CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/static.py
Modified: CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/principal.py 2006-12-01 08:53:54 UTC (rev 632)
+++ CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/principal.py 2006-12-01 18:17:41 UTC (rev 633)
@@ -38,11 +38,12 @@
from twisted.web2.dav.util import joinURL
from twistedcaldav.extensions import ReadOnlyResourceMixIn
-from twistedcaldav.resource import CalendarPrincipalCollectionResource
-from twistedcaldav.static import CalDAVFile, CalendarPrincipalFile
+from twistedcaldav.resource import CalendarPrincipalCollectionResource, CalendarPrincipalResource
from twistedcaldav.directory.idirectory import IDirectoryService
# FIXME: These should not be tied to DAVFile
+# The reason that they is that web2.dav only implements DAV methods on
+# DAVFile instead of DAVResource. That should change.
class PermissionsMixIn (ReadOnlyResourceMixIn):
def defaultAccessControlList(self):
@@ -72,13 +73,13 @@
# FIXME: Smells like a hack
directory.principalCollection = self
- self.provision()
+ self._provision()
# Create children
for recordType in self.directory.recordTypes():
self.putChild(recordType, DirectoryPrincipalTypeResource(self.fp.child(recordType).path, self, recordType))
- def provision(self):
+ def _provision(self):
self.fp.restat(False)
if not self.fp.exists():
self.fp.makedirs()
@@ -101,7 +102,7 @@
raise HTTPError(responsecode.NOT_FOUND)
def getChild(self, name):
- self.provision()
+ self._provision()
return self.putChildren.get(name, None)
def listChildren(self):
@@ -131,9 +132,9 @@
self.recordType = recordType
self._parent = parent
- self.provision()
+ self._provision()
- def provision(self):
+ def _provision(self):
self.fp.restat(False)
if not self.fp.exists():
assert self._parent.exists()
@@ -155,7 +156,7 @@
raise HTTPError(responsecode.NOT_FOUND)
def getChild(self, name, record=None):
- self.provision()
+ self._provision()
if name == "":
return self
@@ -180,19 +181,25 @@
def principalCollections(self):
return self._parent.principalCollections()
-class DirectoryPrincipalResource (PermissionsMixIn, CalendarPrincipalFile):
+class DirectoryPrincipalResource (PermissionsMixIn, CalendarPrincipalResource, DAVFile):
"""
Directory principal resource.
"""
def __init__(self, path, parent, record):
+ """
+ @param path: them path to the file which will back this resource.
+ @param parent: the parent of this resource.
+ @param record: the L{IDirectoryRecord} that this resource represents.
+ """
super(DirectoryPrincipalResource, self).__init__(path, joinURL(parent.principalCollectionURL(), record.shortName))
self.record = record
self._parent = parent
+ self._url = joinURL(parent.principalCollectionURL(), record.shortName)
- self.provision()
+ self._provision()
- def provision(self):
+ def _provision(self):
self.fp.restat(False)
if not self.fp.exists():
assert self._parent.exists()
@@ -266,6 +273,9 @@
# FIXME: Add API to IDirectoryRecord for getting a record URI?
return ()
+ def principalURL(self):
+ return self._url
+
def _getRelatives(self, method, record=None, relatives=None, records=None):
if record is None:
record = self.record
@@ -296,6 +306,16 @@
def principalCollections(self):
return self._parent.principalCollections()
+ def defaultAccessControlList(self):
+ return davxml.ACL(
+ # DAV:read access for this principal only.
+ davxml.ACE(
+ davxml.Principal(davxml.HRef(self.principalURL())),
+ davxml.Grant(davxml.Privilege(davxml.Read())),
+ davxml.Protected(),
+ ),
+ )
+
##
# 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-12-01 08:53:54 UTC (rev 632)
+++ CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/directory/test/test_principal.py 2006-12-01 18:17:41 UTC (rev 633)
@@ -298,14 +298,14 @@
def onError(f):
f.trap(AccessDeniedError)
#print resource.readDeadProperty(davxml.ACL)
- self.fail("%s should have %s privilege" % (principal.sname(), privilege.sname()))
+ self.fail("%s should have %s privilege on %r" % (principal.sname(), privilege.sname(), resource))
d.addErrback(onError)
else:
def onError(f):
f.trap(AccessDeniedError)
def onSuccess(_):
#print resource.readDeadProperty(davxml.ACL)
- self.fail("%s should not have %s privilege" % (principal.sname(), privilege.sname()))
+ self.fail("%s should not have %s privilege on %r" % (principal.sname(), privilege.sname(), resource))
d.addCallback(onSuccess)
d.addErrback(onError)
return d
Modified: CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/repository.py
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/repository.py 2006-12-01 08:53:54 UTC (rev 632)
+++ CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/repository.py 2006-12-01 18:17:41 UTC (rev 633)
@@ -53,7 +53,7 @@
from twistedcaldav import authkerb
from twistedcaldav.logging import RotatingFileAccessLoggingObserver
from twistedcaldav.resource import CalDAVResource
-from twistedcaldav.static import CalendarHomeFile, CalendarPrincipalFile
+from twistedcaldav.static import CalendarHomeFile
from twistedcaldav.directory.idirectory import IDirectoryService
ELEMENT_REPOSITORY = "repository"
Modified: CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/static.py
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/static.py 2006-12-01 08:53:54 UTC (rev 632)
+++ CalendarServer/branches/users/wsanchez/provisioning-2/twistedcaldav/static.py 2006-12-01 18:17:41 UTC (rev 633)
@@ -26,7 +26,6 @@
"ScheduleOutboxFile",
"CalendarHomeFile",
"CalendarHomeProvisioningFile",
- "CalendarPrincipalFile",
"CalendarPrincipalCollectionFile",
]
@@ -423,7 +422,7 @@
if self._parent.record.recordType == "resource":
# Resources should have autorespond turned on by default,
# since they typically don't have someone responding for them.
- child.writeDeadProperty(customxml.TwistedScheduleAutoRespond())
+ self.writeDeadProperty(customxml.TwistedScheduleAutoRespond())
##
# ACL
@@ -701,201 +700,6 @@
else:
return CalendarHomeFile.quotaLimit
-class CalendarPrincipalFile (CalendarPrincipalResource, CalDAVFile):
- """
- Calendar principal resource.
- """
- def __init__(self, path, url):
- """
- @param path: the path to the file which will back the resource.
- @param url: the primary URL for the resource. This is the url which
- will be returned by L{principalURL}.
- """
- assert not url.endswith("/"), "Non-collection URL must not end in '/'"
-
- super(CalendarPrincipalFile, self).__init__(path)
-
- self._url = url
-
- def createSimilarFile(self, path):
- return self.__class__(path, self._url)
-
- ##
- # ACL
- ##
-
- def alternateURIs(self):
- return ()
-
- def principalURL(self):
- return self._url
-
- def groupMembers(self):
- return ()
-
- def groupMemberships(self):
- return ()
-
- def defaultAccessControlList(self):
- return davxml.ACL(
- # DAV:read access for this principal only.
- davxml.ACE(
- davxml.Principal(davxml.HRef(self.principalURL())),
- davxml.Grant(davxml.Privilege(davxml.Read())),
- davxml.Protected(),
- ),
- )
-
- ##
- # CalDAV
- ##
-
- def principalUID(self):
- """
- @return: the user id for this principal.
- """
- return self.fp.basename()
-
- # def provisionCalendarAccount(self, name, pswd, resetacl, cuaddrs, cuhome, cuhomeacls, quota, cals, autorespond, allowdropbox):
- # """
- # Provision the principal and a calendar account for it.
- #
- # @param name: C{str} name (uid) of principal.
- # @param pswd: C{str} password for BASIC authentication, or C{None}.
- # @param resetacl: C{True} if ACLs on the principal resource should be reset.
- # @param cuaddrs: C{list} list of calendar user addresses, or C{None}
- # @param cuhome: C{tuple} of (C{str} - URI of calendar home root, L{DAVResource} - resource of home root)
- # @param cuhomeacls: L{ACL} acls to use on calendar home when resetting ACLs, or C{None} to use default set.
- # @param cals: C{list} list of calendar names to create in the calendar home for this prinicpal.
- # @param autorespond: C{True} if iTIP auto-response is required, C{False} otherwise.
- # @param allowdropbox: C{True} if drop box should be enabled for this user is drop box is supproted, C{False} otherwise.
- # """
- #
- # if pswd:
- # self.writeDeadProperty(TwistedPasswordProperty(pswd))
- # else:
- # self.removeDeadProperty(TwistedPasswordProperty())
- # if name:
- # self.writeDeadProperty(davxml.DisplayName(name))
- # else:
- # self.removeDeadProperty(davxml.DisplayName())
- # if cuaddrs:
- # self.writeDeadProperty(caldavxml.CalendarUserAddressSet(*[davxml.HRef(addr) for addr in cuaddrs]))
- # else:
- # self.removeDeadProperty(caldavxml.CalendarUserAddressSet())
- #
- # if resetacl:
- # self.setAccessControlList(
- # davxml.ACL(
- # davxml.ACE(
- # davxml.Principal(davxml.HRef(self._url)),
- # davxml.Grant(
- # davxml.Privilege(davxml.Read()),
- # ),
- # ),
- # )
- # )
- #
- # # If the user does not have any calendar user addresses we do not create a calendar home for them
- # if not cuaddrs and not cals:
- # return
- #
- # # Create calendar home if we already have the resource, otherwise simply record
- # # the URL as the calendar-home-set
- # if cuhome[1] is None:
- # self.writeDeadProperty(caldavxml.CalendarHomeSet(davxml.HRef(cuhome[0])))
- # else:
- # homeURL = joinURL(cuhome[0], self.principalUID())
- # home = FilePath(os.path.join(cuhome[1].fp.path, self.principalUID()))
- # home_exists = home.exists()
- # if not home_exists:
- # home.createDirectory()
- # home = CalendarHomeFile(home.path)
- #
- # if resetacl or not home_exists:
- # if cuhomeacls:
- # home.setAccessControlList(cuhomeacls.acl)
- # else:
- # home.setAccessControlList(
- # davxml.ACL(
- # davxml.ACE(
- # davxml.Principal(davxml.Authenticated()),
- # davxml.Grant(
- # davxml.Privilege(davxml.Read()),
- # ),
- # ),
- # davxml.ACE(
- # davxml.Principal(davxml.HRef(self._url)),
- # davxml.Grant(
- # davxml.Privilege(davxml.All()),
- # ),
- # TwistedACLInheritable(),
- # ),
- # )
- # )
- #
- # # Handle quota on calendar home
- # home.setQuotaRoot(None, quota)
- #
- # # Save the calendar-home-set, schedule-inbox and schedule-outbox properties
- # self.writeDeadProperty(caldavxml.CalendarHomeSet(davxml.HRef(homeURL + "/")))
- # self.writeDeadProperty(caldavxml.ScheduleInboxURL(davxml.HRef(joinURL(homeURL, "inbox/"))))
- # self.writeDeadProperty(caldavxml.ScheduleOutboxURL(davxml.HRef(joinURL(homeURL, "outbox/"))))
- #
- # # Set ACLs on inbox and outbox
- # if resetacl or not home_exists:
- # inbox = home.getChild("inbox")
- # inbox.setAccessControlList(
- # davxml.ACL(
- # davxml.ACE(
- # davxml.Principal(davxml.Authenticated()),
- # davxml.Grant(
- # davxml.Privilege(caldavxml.Schedule()),
- # ),
- # ),
- # )
- # )
- # if autorespond:
- # inbox.writeDeadProperty(customxml.TwistedScheduleAutoRespond())
- #
- # outbox = home.getChild("outbox")
- # if outbox.hasDeadProperty(davxml.ACL()):
- # outbox.removeDeadProperty(davxml.ACL())
- #
- # calendars = []
- # for calendar in cals:
- # childURL = joinURL(homeURL, calendar)
- # child = CalDAVFile(os.path.join(home.fp.path, calendar))
- # child_exists = child.exists()
- # if not child_exists:
- # c = child.createCalendarCollection()
- # assert c.called
- # c = c.result
- # calendars.append(childURL)
- # if (resetacl or not child_exists):
- # child.setAccessControlList(
- # davxml.ACL(
- # davxml.ACE(
- # davxml.Principal(davxml.Authenticated()),
- # davxml.Grant(
- # davxml.Privilege(caldavxml.ReadFreeBusy()),
- # ),
- # TwistedACLInheritable(),
- # ),
- # )
- # )
- #
- # # Set calendar-free-busy-set on Inbox if not already present
- # inbox = home.getChild("inbox")
- # if not inbox.hasDeadProperty(caldavxml.CalendarFreeBusySet()):
- # fbset = caldavxml.CalendarFreeBusySet(*[davxml.HRef(uri) for uri in calendars])
- # inbox.writeDeadProperty(fbset)
- #
- # # Do drop box if requested
- # if allowdropbox:
- # from twistedcaldav.dropbox import DropBox
- # DropBox.provision(self, (homeURL, home))
-
##
# Utilities
##
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061201/827486b8/attachment.html
More information about the calendarserver-changes
mailing list