[CalendarServer-changes] [3477] CalendarServer/trunk/twistedcaldav/directory

source_changes at macosforge.org source_changes at macosforge.org
Mon Dec 8 13:59:38 PST 2008


Revision: 3477
          http://trac.macosforge.org/projects/calendarserver/changeset/3477
Author:   wsanchez at apple.com
Date:     2008-12-08 13:59:38 -0800 (Mon, 08 Dec 2008)
Log Message:
-----------
Add recordWithGUID() to idirectory with an implementation in directory
similar to recordWithUID().

Make recordWithUID() the same as recordWithGUID() in
appleopendirectory, as recordWithGUID() is way faster.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py
    CalendarServer/trunk/twistedcaldav/directory/directory.py
    CalendarServer/trunk/twistedcaldav/directory/idirectory.py
    CalendarServer/trunk/twistedcaldav/directory/wiki.py

Modified: CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py	2008-12-08 18:55:25 UTC (rev 3476)
+++ CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py	2008-12-08 21:59:38 UTC (rev 3477)
@@ -312,6 +312,8 @@
 
         return record
 
+    recordWithUID = recordWithGUID
+
     def groupsForGUID(self, guid):
         
         # Lookup in index

Modified: CalendarServer/trunk/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/directory.py	2008-12-08 18:55:25 UTC (rev 3476)
+++ CalendarServer/trunk/twistedcaldav/directory/directory.py	2008-12-08 21:59:38 UTC (rev 3477)
@@ -130,6 +130,12 @@
                 return record
         return None
 
+    def recordWithGUID(self, uid):
+        for record in self.allRecords():
+            if record.guid == guid:
+                return record
+        return None
+
     def recordWithCalendarUserAddress(self, address):
         address = normalizeCUAddr(address)
         for record in self.allRecords():

Modified: CalendarServer/trunk/twistedcaldav/directory/idirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/idirectory.py	2008-12-08 18:55:25 UTC (rev 3476)
+++ CalendarServer/trunk/twistedcaldav/directory/idirectory.py	2008-12-08 21:59:38 UTC (rev 3477)
@@ -34,8 +34,9 @@
 
     def recordTypes():
         """
-        @return: a sequence of strings denoting the record types that are kept
-            in the directory.  For example: C{["users", "groups", "resources"]}.
+        @return: a sequence of strings denoting the record types that
+            are kept in the directory.  For example: C{["users",
+            "groups", "resources"]}.
         """
 
     def listRecords(recordType):
@@ -48,34 +49,40 @@
         """
         @param recordType: the type of the record to look up.
         @param shortName: the short name of the record to look up.
-        @return: an L{IDirectoryRecord} provider with the given short name, or
+        @return: an L{IDirectoryRecord} with the given short name, or
             C{None} if no such record exists.
         """
 
     def recordWithUID(uid):
         """
-        @param shortName: the UID of the record to look up.
-        @return: an L{IDirectoryRecord} provider with the given UID, or C{None}
+        @param uid: the UID of the record to look up.
+        @return: an L{IDirectoryRecord} with the given UID, or C{None}
             if no such record exists.
         """
 
+    def recordWithGUID(guid):
+        """
+        @param guid: the GUID of the record to look up.
+        @return: an L{IDirectoryRecord} with the given GUID, or
+            C{None} if no such record exists.
+        """
+
     def recordWithCalendarUserAddress(address):
         """
         @param address: the calendar user address of the record to look up.
-        @return: an L{IDirectoryRecord} provider with the given
-            calendar user address, or C{None} if no such record is
-            found.  Note that some directory services may not be able
-            to locate records by calendar user address, or may return
-            partial results.  Note also that the calendar server may
-            add to the list of valid calendar user addresses for a
-            user, and the directory service may not be aware of these
-            addresses.
+        @return: an L{IDirectoryRecord} with the given calendar user
+            address, or C{None} if no such record is found.  Note that
+            some directory services may not be able to locate records
+            by calendar user address, or may return partial results.
+            Note also that the calendar server may add to the list of
+            valid calendar user addresses for a user, and the
+            directory service may not be aware of these addresses.
         """
 
     def recordsMatchingFields(fields):
         """
-        @return: a deferred sequence of L{IDirectoryRecord}s which match the given
-            fields.
+        @return: a deferred sequence of L{IDirectoryRecord}s which
+            match the given fields.
         """
 
 

Modified: CalendarServer/trunk/twistedcaldav/directory/wiki.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/wiki.py	2008-12-08 18:55:25 UTC (rev 3476)
+++ CalendarServer/trunk/twistedcaldav/directory/wiki.py	2008-12-08 21:59:38 UTC (rev 3477)
@@ -109,11 +109,7 @@
         self.byShortName[shortName] = record
         return record
 
-    def recordWithGUID(self, guid):
-        raise NotImplementedError("recordWithGUID() not valid for wiki records")
 
-
-
 class WikiDirectoryRecord(DirectoryRecord):
     """
     L{DirectoryRecord} implementation for Wikis.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081208/f4c6da7f/attachment.html>


More information about the calendarserver-changes mailing list