[CalendarServer-changes] [1083] CalendarServer/trunk/twistedcaldav/directory/principal.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Jan 22 17:49:17 PST 2007


Revision: 1083
          http://trac.macosforge.org/projects/calendarserver/changeset/1083
Author:   wsanchez at apple.com
Date:     2007-01-22 17:49:17 -0800 (Mon, 22 Jan 2007)

Log Message:
-----------
Handle full URLs.
Fix undefined symbol bug in principalForCalendarUserAddress()

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/principal.py

Modified: CalendarServer/trunk/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/principal.py	2007-01-23 01:48:33 UTC (rev 1082)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py	2007-01-23 01:49:17 UTC (rev 1083)
@@ -104,15 +104,33 @@
         return self.principalForShortName(record.recordType, record.shortName)
 
     def _principalForURI(self, uri):
-        scheme, host, path, params, query, fragment = urlparse(uri)
+        scheme, netloc, path, params, query, fragment = urlparse(uri)
 
         if scheme == "":
             pass
+
         elif scheme in ("http", "https"):
-            # FIXME: Check that the hostname matches this server
-            # This means we need to know our hostname/port combos
-            log.msg("**** %s" % (host,))
-            pass
+            # Get rid of possible user/password nonsense
+            netloc = netloc.split("@", 1)[-1]
+
+            # Get host/port
+            netloc = netloc.split(":", 1)
+
+            host = netloc[0]
+            if len(netloc) == 1 or netloc[1] == "":
+                port = 80
+            else:
+                port = int(netloc[1])
+
+            if host != config.ServerHostName:
+                return None
+
+            if port != {
+                "http" : config.Port,
+                "https": config.SSLPort,
+            }[scheme]:
+                return None
+
         elif scheme == "urn":
             if path.startswith("uuid:"):
                 return self.principalForGUID(path[5:])
@@ -143,11 +161,10 @@
             return principal
 
         # Next try looking it up in the directory
-        for addr in addresses:
-            record = self.directory.recordWithCalendarUserAddress(addr)
-            if record is not None:
-                return self.principalForRecord(record)
-        
+        record = self.directory.recordWithCalendarUserAddress(address)
+        if record is not None:
+            return self.principalForRecord(record)
+
         return None
 
     ##

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070122/7a9a84fd/attachment.html


More information about the calendarserver-changes mailing list