[CalendarServer-changes] [698]
CalendarServer/trunk/twistedcaldav/directory/principal.py
source_changes at macosforge.org
source_changes at macosforge.org
Tue Dec 5 14:05:05 PST 2006
Revision: 698
http://trac.macosforge.org/projects/calendarserver/changeset/698
Author: cdaboo at apple.com
Date: 2006-12-05 14:05:04 -0800 (Tue, 05 Dec 2006)
Log Message:
-----------
Allow relative principal URIs to be matched as a calendar user address. Punt on absolute URIs for now.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/principal.py
Modified: CalendarServer/trunk/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/principal.py 2006-12-05 20:05:42 UTC (rev 697)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py 2006-12-05 22:05:04 UTC (rev 698)
@@ -26,6 +26,8 @@
"DirectoryPrincipalResource",
]
+from urllib import unquote
+
from twisted.python import log
from twisted.python.failure import Failure
from twisted.internet.defer import succeed
@@ -91,7 +93,35 @@
return None
return typeResource.getChild(record.shortName)
+ def principalForURI(self, uri):
+ if uri.startswith(self._url):
+ path = uri[len(self._url) - 1:]
+ else:
+ #TODO: figure out absolute URIs
+ #absuri = request.unparseURL(path=self._url)
+ #if uri.startswith(absuri):
+ # path = uri[len(absuri) - 1:]
+ #else:
+ # path = None
+ path = None
+
+ if path:
+ segments = unquote(path).split("/")
+ if segments[0] == "" and len(segments) == 3:
+ typeResource = self.getChild(segments[1])
+ if typeResource is not None:
+ principalResource = typeResource.getChild(segments[2])
+ if principalResource:
+ return principalResource
+
+ return None
+
def principalForCalendarUserAddress(self, address):
+ # First see if the address is a principal URI
+ principal = self.principalForURI(address)
+ if principal:
+ return principal
+
record = self.directory.recordWithCalendarUserAddress(address)
if record is None:
return None
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061205/0b8981ee/attachment.html
More information about the calendarserver-changes
mailing list