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

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 3 15:00:45 PST 2006


Revision: 363
          http://trac.macosforge.org/projects/calendarserver/changeset/363
Author:   wsanchez at apple.com
Date:     2006-11-03 15:00:44 -0800 (Fri, 03 Nov 2006)

Log Message:
-----------
Rename opendirectory to appleopendirectory because Python's import is dumb.

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

Added Paths:
-----------
    CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py

Removed Paths:
-------------
    CalendarServer/trunk/twistedcaldav/directory/opendirectory.py

Copied: CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py (from rev 361, CalendarServer/trunk/twistedcaldav/directory/opendirectory.py)
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py	                        (rev 0)
+++ CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py	2006-11-03 23:00:44 UTC (rev 363)
@@ -0,0 +1,105 @@
+##
+# Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# DRI: Cyrus Daboo, cdaboo at apple.com
+##
+
+"""
+Apple Open Directory implementation.
+"""
+
+__all__ = [
+    "OpenDirectoryService",
+    "OpenDirectoryRecord",
+]
+
+import opendirectory
+
+from twistedcaldav.directory.directory import DirectoryService, DirectoryRecord
+
+class OpenDirectoryService(DirectoryService):
+    """
+    Open Directory implementation of L{IDirectoryService}.
+    """
+    def __init__(self, node="/Search"):
+        directory = opendirectory.odInit(node)
+        if directory is None:
+            raise ValueError("Failed to open Open Directory Node: %s" % (node,))
+
+        self._directory = directory
+
+    def recordTypes(self):
+        return ("users", "groups", "resources")
+
+    def listRecords(self, recordType):
+        def makeRecord(shortName, guid, lastModified, principalURI):
+            if not guid:
+                return None
+
+            ##
+            # FIXME: Also verify that principalURI is on this server
+            # Which probably means that the host information needs to be on
+            # the site object, and that we need the site object passed to
+            # __init__() here.
+            ##
+
+            return OpenDirectoryRecord(
+                directory = self,
+                recordType = recordType,
+                guid = guid,
+                shortName = shortName,
+                fullName = None,
+            )
+
+        if recordType == "users":
+            for data in opendirectory.listUsers(self._directory):
+                yield makeRecord(*data)
+            return
+
+        if recordType == "groups":
+            for data in opendirectory.listGroups(self._directory):
+                yield makeRecord(*data)
+            return
+
+        if recordType == "resources":
+            for data in opendirectory.listResources(self._directory):
+                yield makeRecord(*data)
+            return
+
+        raise AssertionError("Unknown Open Directory record type: %s" % (recordType,))
+
+    def userWithShortName(shortName):
+        result = opendirectory.listUsersWithAttributes(self._directory, [shortName])
+        if shortName not in result:
+            return None
+        result = result[shortName]
+
+        return OpenDirectoryRecord(
+            directory = self,
+            recordType = "user",
+            guid = result[dsattributes.attrGUID],
+            shortName = shortName,
+            fullName = result[dsattributes.attrRealName],
+        )
+
+class OpenDirectoryRecord(DirectoryRecord):
+    """
+    Open Directory implementation of L{IDirectoryRecord}.
+    """
+    def authenticate(self, credentials):
+        if isinstance(credentials, credentials.UsernamePassword):
+            return opendirectory.authenticateUser(self.directory, self.shortName, credentials.password)
+
+        return False

Modified: CalendarServer/trunk/twistedcaldav/directory/idirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/idirectory.py	2006-11-03 22:54:47 UTC (rev 362)
+++ CalendarServer/trunk/twistedcaldav/directory/idirectory.py	2006-11-03 23:00:44 UTC (rev 363)
@@ -54,11 +54,11 @@
     """
     Directory Record
     """
-    directory  Attribute("The L{IDirectoryService} this record exists in.")
-    recordType Attribute("The type of this record.")
-    guid       Attribute("The GUID of this record.")
-    shortName  Attribute("The name of this record.")
-    fullName   Attribute("The full name of this record.")
+    directory  = Attribute("The L{IDirectoryService} this record exists in.")
+    recordType = Attribute("The type of this record.")
+    guid       = Attribute("The GUID of this record.")
+    shortName  = Attribute("The name of this record.")
+    fullName   = Attribute("The full name of this record.")
 
     def authenticate(credentials):
         """

Deleted: CalendarServer/trunk/twistedcaldav/directory/opendirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/opendirectory.py	2006-11-03 22:54:47 UTC (rev 362)
+++ CalendarServer/trunk/twistedcaldav/directory/opendirectory.py	2006-11-03 23:00:44 UTC (rev 363)
@@ -1,105 +0,0 @@
-##
-# Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# DRI: Cyrus Daboo, cdaboo at apple.com
-##
-
-"""
-Apple Open Directory implementation.
-"""
-
-__all__ = [
-    "OpenDirectoryService",
-    "OpenDirectoryRecord",
-]
-
-import opendirectory
-
-from twistedcaldav.directory.directory import DirectoryService, DirectoryRecord
-
-class OpenDirectoryService(DirectoryService):
-    """
-    Open Directory implementation of L{IDirectoryService}.
-    """
-    def __init__(self, node="/Search"):
-        directory = opendirectory.odInit(node)
-        if directory is None:
-            raise ValueError("Failed to open Open Directory Node: %s" % (node,))
-
-        self._directory = directory
-
-    def recordTypes(self):
-        return ("users", "groups", "resources")
-
-    def listRecords(self, recordType):
-        def makeRecord(shortName, guid, lastModified, principalURI):
-            if not guid:
-                return None
-
-            ##
-            # FIXME: Also verify that principalURI is on this server
-            # Which probably means that the host information needs to be on
-            # the site object, and that we need the site object passed to
-            # __init__() here.
-            ##
-
-            return OpenDirectoryRecord(
-                directory = self,
-                recordType = recordType,
-                guid = guid,
-                shortName = shortName,
-                fullName = None,
-            )
-
-        if recordType == "users":
-            for data in opendirectory.listUsers(self._directory):
-                yield makeRecord(*data)
-            return
-
-        if recordType == "groups":
-            for data in opendirectory.listGroups(self._directory):
-                yield makeRecord(*data)
-            return
-
-        if recordType == "resources":
-            for data in opendirectory.listResources(self._directory):
-                yield makeRecord(*data)
-            return
-
-        raise AssertionError("Unknown Open Directory record type: %s" % (recordType,))
-
-    def userWithShortName(shortName):
-        result = opendirectory.listUsersWithAttributes(self._directory, [shortName])
-        if shortName not in result:
-            return None
-        result = result[shortName]
-
-        return OpenDirectoryRecord(
-            directory = self,
-            recordType = "user",
-            guid = result[dsattributes.attrGUID],
-            shortName = shortName,
-            fullName = result[dsattributes.attrRealName],
-        )
-
-class OpenDirectoryRecord(DirectoryRecord):
-    """
-    Open Directory implementation of L{IDirectoryRecord}.
-    """
-    def authenticate(self, credentials):
-        if isinstance(credentials, credentials.UsernamePassword):
-            return opendirectory.authenticateUser(self.directory, self.shortName, credentials.password)
-
-        return False

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


More information about the calendarserver-changes mailing list