[CalendarServer-changes] [1078]
CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/
directory/appleopendirectory.py
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jan 19 16:45:26 PST 2007
Revision: 1078
http://trac.macosforge.org/projects/calendarserver/changeset/1078
Author: wsanchez at apple.com
Date: 2007-01-19 16:45:26 -0800 (Fri, 19 Jan 2007)
Log Message:
-----------
Simplify
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/directory/appleopendirectory.py
Modified: CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/directory/appleopendirectory.py
===================================================================
--- CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/directory/appleopendirectory.py 2007-01-20 00:42:33 UTC (rev 1077)
+++ CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/directory/appleopendirectory.py 2007-01-20 00:45:26 UTC (rev 1078)
@@ -55,8 +55,9 @@
def __init__(self, node="/Search", dosetup=True):
"""
@param node: an OpenDirectory node name to bind to.
- @param dosetup: if C{True} then the directory records are initialized,
- if C{False} they are not. This is only set to C{False} when doing unit tests.
+ @param dosetup: if C{True} then the directory records are initialized,
+ if C{False} they are not.
+ This should only be set to C{False} when doing unit tests.
"""
try:
directory = opendirectory.odInit(node)
@@ -72,8 +73,15 @@
self._delayedCalls = set()
if dosetup:
- self.setup()
+ try:
+ self._lookupVHostRecord()
+ except Exception, e:
+ log.err("Unable to locate virtual host record: %s" % (e,))
+ raise
+ for recordType in self.recordTypes():
+ self.recordsForType(recordType)
+
def __cmp__(self, other):
if not isinstance(other, DirectoryRecord):
return super(DirectoryRecord, self).__eq__(other)
@@ -117,19 +125,14 @@
)
# Must have a single result
- if len(results) == 0:
+ if len(results) != 1:
raise OpenDirectoryInitError(
- "Open Directory (node=%s) no /Computers record with EnetAddress: %s"
- % (self.realmName, macaddr)
+ "Open Directory (node=%s) has %s (!= 1) /Computers records with EnetAddress: %s"
+ % (self.realmName, len(results), macaddr)
)
- elif len(results) > 1:
- raise OpenDirectoryInitError(
- "Open Directory (node=%s) multiple /Computers records with EnetAddress: %s"
- % (self.realmName, macaddr)
- )
- else:
- self.computerRecordName = results.keys()[0]
- record = results[self.computerRecordName]
+
+ self.computerRecordName = results.keys()[0]
+ record = results[self.computerRecordName]
# Get XMLPlist value
plist = record.get(dsattributes.kDS1AttrXMLPlist, None)
@@ -281,16 +284,6 @@
return result
- def setup(self):
- try:
- self._lookupVHostRecord()
- except Exception, e:
- log.err("Unable to locate virtual host record: %s" % (e,))
- raise
-
- for recordType in self.recordTypes():
- self.recordsForType(recordType)
-
def recordTypes(self):
return (
DirectoryService.recordType_users,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070119/605bfee8/attachment.html
More information about the calendarserver-changes
mailing list