[CalendarServer-changes] [3181] CalendarServer/branches/users/sagen/wikitype-3152
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 17 11:24:57 PDT 2008
Revision: 3181
http://trac.macosforge.org/projects/calendarserver/changeset/3181
Author: sagen at apple.com
Date: 2008-10-17 11:24:57 -0700 (Fri, 17 Oct 2008)
Log Message:
-----------
Consolidation of getWikiACL code
Modified Paths:
--------------
CalendarServer/branches/users/sagen/wikitype-3152/conf/caldavd.plist
CalendarServer/branches/users/sagen/wikitype-3152/twistedcaldav/directory/calendar.py
CalendarServer/branches/users/sagen/wikitype-3152/twistedcaldav/directory/principal.py
CalendarServer/branches/users/sagen/wikitype-3152/twistedcaldav/directory/wiki.py
Modified: CalendarServer/branches/users/sagen/wikitype-3152/conf/caldavd.plist
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3152/conf/caldavd.plist 2008-10-17 17:55:41 UTC (rev 3180)
+++ CalendarServer/branches/users/sagen/wikitype-3152/conf/caldavd.plist 2008-10-17 18:24:57 UTC (rev 3181)
@@ -214,6 +214,12 @@
<string></string>
</dict>
+ <!-- Wikiserver authentication -->
+ <key>Wiki</key>
+ <dict>
+ <key>Enabled</key>
+ <false/>
+ </dict>
</dict>
Modified: CalendarServer/branches/users/sagen/wikitype-3152/twistedcaldav/directory/calendar.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3152/twistedcaldav/directory/calendar.py 2008-10-17 17:55:41 UTC (rev 3180)
+++ CalendarServer/branches/users/sagen/wikitype-3152/twistedcaldav/directory/calendar.py 2008-10-17 18:24:57 UTC (rev 3181)
@@ -42,9 +42,12 @@
from twistedcaldav.resource import CalDAVResource
from twistedcaldav.schedule import ScheduleInboxResource, ScheduleOutboxResource
from twistedcaldav.directory.idirectory import IDirectoryService
-from twistedcaldav.directory.wiki import WikiDirectoryService, getWikiACL
+from twistedcaldav.directory.wiki import getWikiACL
from twistedcaldav.directory.resource import AutoProvisioningResourceMixIn
+from twistedcaldav.log import Logger
+log = Logger()
+
# Use __underbars__ convention to avoid conflicts with directory resource types.
uidsResourceName = "__uids__"
@@ -414,23 +417,16 @@
@inlineCallbacks
def accessControlList(self, request, inheritance=True, expanding=False, inherited_aces=None):
- # If this is a wiki-related resource, ACL depends on wiki server:
- if self.record.recordType == WikiDirectoryService.recordType_wikis:
+ wikiACL = (yield getWikiACL(self, request))
+ if wikiACL is not None:
+ # ACL depends on wiki server...
+ log.info("Wiki ACL: %s" % (wikiACL,))
+ returnValue(wikiACL)
+ else:
+ # ...otherwise permissions are fixed, and are not subject to
+ # inheritance rules, etc.
+ returnValue(self.defaultAccessControlList())
- if hasattr(request, 'wikiACL'):
- # We've already looked up wikiACL during this request
- returnValue(request.wikiACL)
-
- # query the wiki server
- request.wikiACL = yield (getWikiACL(request,
- self.record.shortName))
-
- returnValue(request.wikiACL)
-
- # ...otherwise permissions are fixed, and are not subject to
- # inheritance rules, etc.
- returnValue(self.defaultAccessControlList())
-
def principalCollections(self):
return self.parent.principalCollections()
Modified: CalendarServer/branches/users/sagen/wikitype-3152/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3152/twistedcaldav/directory/principal.py 2008-10-17 17:55:41 UTC (rev 3180)
+++ CalendarServer/branches/users/sagen/wikitype-3152/twistedcaldav/directory/principal.py 2008-10-17 18:24:57 UTC (rev 3181)
@@ -56,6 +56,7 @@
from twistedcaldav.directory.idirectory import IDirectoryService
from twistedcaldav.log import Logger
from twistedcaldav import caldavxml, customxml
+from twistedcaldav.directory.wiki import getWikiACL
log = Logger()
@@ -73,27 +74,17 @@
@inlineCallbacks
def accessControlList(self, request, inheritance=True, expanding=False, inherited_aces=None):
- log.info("REQUEST in accessControlList: %s" % (request.authzUser))
- # TODO: Fix the circular dependency between wiki.py and principal.py
- from twistedcaldav.directory.wiki import WikiDirectoryService, getWikiACL
- # If this is a wiki-related principal, ACL depends on wiki server:
- if self.record.recordType == WikiDirectoryService.recordType_wikis:
+ wikiACL = (yield getWikiACL(self, request))
+ if wikiACL is not None:
+ # ACL depends on wiki server...
+ log.info("Wiki ACL: %s" % (wikiACL,))
+ returnValue(wikiACL)
+ else:
+ # ...otherwise permissions are fixed, and are not subject to
+ # inheritance rules, etc.
+ returnValue(self.defaultAccessControlList())
- if hasattr(request, 'wikiACL'):
- # We've already looked up wikiACL during this request
- returnValue(request.wikiACL)
- # query the wiki server
- request.wikiACL = (yield getWikiACL(request, self.record.shortName))
- log.info("Wiki ACL: %s" % (request.wikiACL,))
- returnValue(request.wikiACL)
-
-
- # ...otherwise permissions are fixed, and are not subject to
- # inheritance rules, etc.
- returnValue(self.defaultAccessControlList())
-
-
class DirectoryProvisioningResource (
PermissionsMixIn,
CalendarPrincipalCollectionResource,
Modified: CalendarServer/branches/users/sagen/wikitype-3152/twistedcaldav/directory/wiki.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3152/twistedcaldav/directory/wiki.py 2008-10-17 17:55:41 UTC (rev 3180)
+++ CalendarServer/branches/users/sagen/wikitype-3152/twistedcaldav/directory/wiki.py 2008-10-17 18:24:57 UTC (rev 3181)
@@ -38,7 +38,6 @@
from twistedcaldav.directory.directory import (DirectoryService,
DirectoryRecord,
UnknownRecordTypeError)
-from twistedcaldav.directory.principal import DirectoryCalendarPrincipalResource
from twistedcaldav.log import Logger
log = Logger()
@@ -49,7 +48,7 @@
"""
baseGUID = "d79ef1e0-9a42-11dd-ad8b-0800200c9a66"
- realmName = "Wiki"
+ realmName = None
recordType_wikis = "wikis"
@@ -66,7 +65,7 @@
return (WikiDirectoryService.recordType_wikis,)
def listRecords(self, recordType):
- return []
+ return ()
def recordWithShortName(self, recordType, shortName):
if recordType != WikiDirectoryService.recordType_wikis:
@@ -113,16 +112,24 @@
@inlineCallbacks
-def getWikiACL(request, wikiID):
+def getWikiACL(resource, request):
+ from twistedcaldav.directory.principal import DirectoryCalendarPrincipalResource
+
+ if (not hasattr(resource, "record") or
+ resource.record.recordType != WikiDirectoryService.recordType_wikis):
+ returnValue(None)
+
+ if hasattr(request, 'wikiACL'):
+ returnValue(request.wikiACL)
+
wikiConfig = config.Authentication["Wiki"]
-
userID = "unauthenticated"
+ wikiID = resource.record.shortName
try:
url = str(request.authzUser.children[0])
principal = (yield request.locateResource(url))
- # TODO: Fix the circular dependency between wiki.py and calendar.py
if isinstance(principal, DirectoryCalendarPrincipalResource):
userID = principal.record.guid
except:
@@ -139,37 +146,35 @@
wikiID, access))
if access == "read":
- returnValue(
- davxml.ACL(
- davxml.ACE(
- request.authnUser,
- davxml.Grant(
- davxml.Privilege(davxml.Read()),
- ),
- TwistedACLInheritable(),
- )
- )
- )
+ request.wikiACL = davxml.ACL(
+ davxml.ACE(
+ request.authnUser,
+ davxml.Grant(
+ davxml.Privilege(davxml.Read()),
+ ),
+ TwistedACLInheritable(),
+ )
+ )
+ returnValue(request.wikiACL)
elif access in ("write", "admin"):
- returnValue(
- davxml.ACL(
- davxml.ACE(
- request.authnUser,
- davxml.Grant(
- davxml.Privilege(davxml.Read()),
- ),
- TwistedACLInheritable(),
- ),
- davxml.ACE(
- request.authnUser,
- davxml.Grant(
- davxml.Privilege(davxml.Write()),
- ),
- TwistedACLInheritable(),
- )
- )
- )
+ request.wikiACL = davxml.ACL(
+ davxml.ACE(
+ request.authnUser,
+ davxml.Grant(
+ davxml.Privilege(davxml.Read()),
+ ),
+ TwistedACLInheritable(),
+ ),
+ davxml.ACE(
+ request.authnUser,
+ davxml.Grant(
+ davxml.Privilege(davxml.Write()),
+ ),
+ TwistedACLInheritable(),
+ )
+ )
+ returnValue(request.wikiACL)
else: # "no-access":
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081017/b4a07fcb/attachment-0001.html
More information about the calendarserver-changes
mailing list