[CalendarServer-changes] [3186] CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 17 17:50:06 PDT 2008
Revision: 3186
http://trac.macosforge.org/projects/calendarserver/changeset/3186
Author: sagen at apple.com
Date: 2008-10-17 17:50:06 -0700 (Fri, 17 Oct 2008)
Log Message:
-----------
Checkpoint -- adds record.uid. For wikis, uid is wiki-<name>
Modified Paths:
--------------
CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/accesslog.py
CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/aggregate.py
CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/calendar.py
CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/directory.py
CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/idirectory.py
CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/principal.py
CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/test/test_principal.py
CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/test/util.py
CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/wiki.py
CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/static.py
Modified: CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/accesslog.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/accesslog.py 2008-10-18 00:47:13 UTC (rev 3185)
+++ CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/accesslog.py 2008-10-18 00:50:06 UTC (rev 3186)
@@ -81,7 +81,7 @@
def convertUIDtoShortName(uid):
uid = uid.rstrip("/")
uid = uid[uid.rfind("/") + 1:]
- record = request.site.resource.getDirectory().recordWithGUID(uid)
+ record = request.site.resource.getDirectory().recordWithUID(uid)
if record:
if record.recordType == DirectoryService.recordType_users:
return record.shortName
Modified: CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/aggregate.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/aggregate.py 2008-10-18 00:47:13 UTC (rev 3185)
+++ CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/aggregate.py 2008-10-18 00:50:06 UTC (rev 3186)
@@ -97,9 +97,12 @@
def recordWithShortName(self, recordType, shortName):
return self._query("recordWithShortName", recordType, shortName)
- def recordWithGUID(self, guid):
- return self._queryAll("recordWithGUID", guid)
+ # def recordWithGUID(self, guid):
+ # return self._queryAll("recordWithGUID", guid)
+ def recordWithUID(self, uid):
+ return self._queryAll("recordWithUID", uid)
+
def recordWithCalendarUserAddress(self, address):
return self._queryAll("recordWithCalendarUserAddress", address)
Modified: CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/calendar.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/calendar.py 2008-10-18 00:47:13 UTC (rev 3185)
+++ CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/calendar.py 2008-10-18 00:50:06 UTC (rev 3186)
@@ -123,7 +123,7 @@
if uidResource is None:
return None
else:
- return uidResource.getChild(record.guid)
+ return uidResource.getChild(record.uid)
##
# DAV
@@ -220,7 +220,7 @@
return self
if record is None:
- record = self.directory.recordWithGUID(name)
+ record = self.directory.recordWithUID(name)
if record is None:
return None
@@ -336,7 +336,7 @@
raise NotImplementedError("Subclass must implement provisionChild()")
def url(self):
- return joinURL(self.parent.url(), self.record.guid)
+ return joinURL(self.parent.url(), self.record.uid)
##
## While the underlying primary location is GUID-based, we want
## the canonical user-facing location to be recordType &
Modified: CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/directory.py 2008-10-18 00:47:13 UTC (rev 3185)
+++ CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/directory.py 2008-10-18 00:50:06 UTC (rev 3186)
@@ -121,9 +121,9 @@
def recordWithShortName(self, recordType, shortName):
raise NotImplementedError("Subclass must implement recordWithShortName()")
- def recordWithGUID(self, guid):
+ def recordWithUID(self, uid):
for record in self.allRecords():
- if record.guid == guid:
+ if record.uid == uid:
return record
return None
@@ -227,6 +227,7 @@
self, service, recordType, guid, shortName, fullName,
firstName, lastName, emailAddresses,
calendarUserAddresses, autoSchedule, enabledForCalendaring=True,
+ uid=None,
):
assert service.realmName is not None
assert recordType
@@ -235,6 +236,9 @@
if not guid:
guid = uuidFromName(service.guid, "%s:%s" % (recordType, shortName))
+ if uid is None:
+ uid = guid
+
if enabledForCalendaring:
calendarUserAddresses.add("urn:uuid:%s" % (guid,))
else:
@@ -243,6 +247,7 @@
self.service = service
self.recordType = recordType
self.guid = guid
+ self.uid = uid
self.shortName = shortName
self.fullName = fullName
self.firstName = firstName
Modified: CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/idirectory.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/idirectory.py 2008-10-18 00:47:13 UTC (rev 3185)
+++ CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/idirectory.py 2008-10-18 00:50:06 UTC (rev 3186)
@@ -52,10 +52,10 @@
C{None} if no such record exists.
"""
- def recordWithGUID(guid):
+ def recordWithUID(uid):
"""
- @param shortName: the GUID of the record to look up.
- @return: an L{IDirectoryRecord} provider with the given GUID, or C{None}
+ @param shortName: the UID of the record to look up.
+ @return: an L{IDirectoryRecord} provider with the given UID, or C{None}
if no such record exists.
"""
@@ -86,6 +86,7 @@
service = Attribute("The L{IDirectoryService} this record exists in.")
recordType = Attribute("The type of this record.")
guid = Attribute("The GUID of this record.")
+ uid = Attribute("The UID of this record.")
shortName = Attribute("The name of this record.")
fullName = Attribute("The full name of this record.")
firstName = Attribute("The first name of this record.")
Modified: CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/principal.py 2008-10-18 00:47:13 UTC (rev 3185)
+++ CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/principal.py 2008-10-18 00:50:06 UTC (rev 3186)
@@ -122,16 +122,13 @@
def principalForUser(self, user):
return self.principalForShortName(DirectoryService.recordType_users, user)
- def principalForGUID(self, guid):
- return self.principalForRecord(self.directory.recordWithGUID(guid))
-
def principalForUID(self, uid):
raise NotImplementedError("Subclass must implement principalForUID()")
def principalForRecord(self, record):
if record is None:
return None
- return self.principalForUID(record.guid)
+ return self.principalForUID(record.uid)
def principalForCalendarUserAddress(self, address):
raise NotImplementedError("Subclass must implement principalForCalendarUserAddress()")
@@ -238,7 +235,7 @@
elif scheme == "urn":
if path.startswith("uuid:"):
- return self.principalForGUID(path[5:])
+ return self.principalForUID(path[5:])
else:
return None
else:
@@ -397,7 +394,7 @@
primaryUID = name
subType = None
- record = self.directory.recordWithGUID(primaryUID)
+ record = self.directory.recordWithUID(primaryUID)
if record is None:
log.err("No principal found for UID: %s" % (name,))
@@ -647,7 +644,7 @@
return self.parent.principalCollections()
def principalUID(self):
- return self.record.guid
+ return self.record.uid
##
# Static
Modified: CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/test/test_principal.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/test/test_principal.py 2008-10-18 00:47:13 UTC (rev 3185)
+++ CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/test/test_principal.py 2008-10-18 00:50:06 UTC (rev 3186)
@@ -146,12 +146,12 @@
self.failIf(userResource is None)
self.assertEquals(user, userResource.record)
- def test_principalForGUID(self):
+ def test_principalForUID(self):
"""
- DirectoryPrincipalProvisioningResource.principalForGUID()
+ DirectoryPrincipalProvisioningResource.principalForUID()
"""
for provisioningResource, recordType, recordResource, record in self._allRecords():
- principal = provisioningResource.principalForGUID(record.guid)
+ principal = provisioningResource.principalForUID(record.uid)
self.failIf(principal is None)
self.assertEquals(record, principal.record)
Modified: CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/test/util.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/test/util.py 2008-10-18 00:47:13 UTC (rev 3185)
+++ CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/test/util.py 2008-10-18 00:50:06 UTC (rev 3186)
@@ -127,14 +127,14 @@
continue
self.assertEquals(record, None)
- def test_recordWithGUID(self):
+ def test_recordWithUID(self):
service = self.service()
record = None
for shortName, what in self.allEntries():
guid = what["guid"]
if guid is not None:
- record = service.recordWithGUID(guid)
+ record = service.recordWithUID(guid)
self.compare(record, shortName, what)
if record is None:
Modified: CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/wiki.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/wiki.py 2008-10-18 00:47:13 UTC (rev 3185)
+++ CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/directory/wiki.py 2008-10-18 00:50:06 UTC (rev 3186)
@@ -52,13 +52,15 @@
recordType_wikis = "wikis"
+ UIDPrefix = "wiki-"
+
def __repr__(self):
return "<%s %r>" % (self.__class__.__name__, self.realmName)
def __init__(self):
super(WikiDirectoryService, self).__init__()
- self.byGUID = {}
+ self.byUID = {}
self.byShortName = {}
def recordTypes(self):
@@ -72,21 +74,44 @@
raise UnknownRecordTypeError(recordType)
if self.byShortName.has_key(shortName):
- return self.byShortName[shortName]
+ record = self.byShortName[shortName]
+ self.log_info("Returning existing wiki record with UID %s" %
+ (record.uid,))
+ return record
+ record = self._addRecord(shortName)
+ return record
+
+ def recordWithUID(self, uid):
+
+ if self.byUID.has_key(uid):
+ record = self.byUID[uid]
+ self.log_info("Returning existing wiki record with UID %s" %
+ (record.uid,))
+ return record
+
+ if uid.startswith(self.UIDPrefix):
+ shortName = uid[len(self.UIDPrefix):]
+ record = self._addRecord(shortName)
+ return record
+ else:
+ return None
+
+ def _addRecord(self, shortName):
+
record = WikiDirectoryRecord(
self,
WikiDirectoryService.recordType_wikis,
shortName,
None
)
- self.log_info("Returning wiki record with GUID %s" % (record.guid,))
- self.byGUID[record.guid] = record
+ self.log_info("Creating wiki record with GUID %s" % (record.guid,))
+ self.byUID[record.uid] = record
self.byShortName[shortName] = record
return record
def recordWithGUID(self, guid):
- return self.byGUID.get(guid, None)
+ raise NotImplementedError("recordWithGUID() not valid for wiki records")
@@ -100,6 +125,7 @@
service=service,
recordType=recordType,
guid=None,
+ uid="%s%s" % (WikiDirectoryService.UIDPrefix, shortName),
shortName=shortName,
fullName=shortName,
firstName="",
@@ -139,10 +165,12 @@
proxy = Proxy(wikiConfig["URL"])
try:
+ log.info("Looking up Wiki ACL for: user [%s], wiki [%s]" % (userID,
+ wikiID))
access = (yield proxy.callRemote(wikiConfig["WikiMethod"],
userID, wikiID))
- log.info("getWikiACL: user [%s], wiki [%s], access [%s]" % (userID,
+ log.info("Wiki ACL result: user [%s], wiki [%s], access [%s]" % (userID,
wikiID, access))
if access == "read":
@@ -196,7 +224,7 @@
except Fault, fault:
- log.info("getWikiACL: user [%s], wiki [%s], FAULT [%s]" % (userID,
+ log.info("Wiki ACL result: user [%s], wiki [%s], FAULT [%s]" % (userID,
wikiID, fault))
if fault.faultCode == 2: # non-existent user
Modified: CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/static.py
===================================================================
--- CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/static.py 2008-10-18 00:47:13 UTC (rev 3185)
+++ CalendarServer/branches/users/sagen/wikitype-3184/twistedcaldav/static.py 2008-10-18 00:50:06 UTC (rev 3186)
@@ -535,7 +535,7 @@
self.homeResourceClass = homeResourceClass
def provisionChild(self, name):
- record = self.directory.recordWithGUID(name)
+ record = self.directory.recordWithUID(name)
if record is None:
log.msg("No directory record with GUID %r" % (name,))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081017/b33b5f33/attachment-0001.html
More information about the calendarserver-changes
mailing list