[CalendarServer-changes] [4093] CalendarServer/trunk/twistedcaldav/directory/ cachingappleopendirectory.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Apr 27 15:44:27 PDT 2009
Revision: 4093
http://trac.macosforge.org/projects/calendarserver/changeset/4093
Author: sagen at apple.com
Date: 2009-04-27 15:44:27 -0700 (Mon, 27 Apr 2009)
Log Message:
-----------
A workaround for email address searches not working when asking for location and resource types
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/cachingappleopendirectory.py
Modified: CalendarServer/trunk/twistedcaldav/directory/cachingappleopendirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/cachingappleopendirectory.py 2009-04-27 20:32:14 UTC (rev 4092)
+++ CalendarServer/trunk/twistedcaldav/directory/cachingappleopendirectory.py 2009-04-27 22:44:27 UTC (rev 4093)
@@ -449,12 +449,16 @@
attrs.append(dsattributes.kDSNAttrNestedGroups)
elif recordType == DirectoryService.recordType_locations:
- listRecordTypes.append(dsattributes.kDSStdRecordTypePlaces)
+ # Email addresses and locations don't mix
+ if indexType != self.INDEX_TYPE_EMAIL:
+ listRecordTypes.append(dsattributes.kDSStdRecordTypePlaces)
# MOR: possibly can be removed
attrs.append(dsattributes.kDSNAttrResourceInfo)
elif recordType == DirectoryService.recordType_resources:
- listRecordTypes.append(dsattributes.kDSStdRecordTypeResources)
+ # Email addresses and resources don't mix
+ if indexType != self.INDEX_TYPE_EMAIL:
+ listRecordTypes.append(dsattributes.kDSStdRecordTypeResources)
# MOR: possibly can be removed
attrs.append(dsattributes.kDSNAttrResourceInfo)
@@ -470,25 +474,38 @@
query = dsquery.match(queryattr, indexKey, dsattributes.eDSExact)
try:
- self.log_debug("opendirectory.queryRecordsWithAttribute_list(%r,%r,%r,%r,%r,%r,%r)" % (
+ results = opendirectory.queryRecordsWithAttributes(
self.directory,
- query.attribute,
- query.value,
- query.matchType,
- False,
+ "(%s=%s)" % (queryattr, query.value),
+ True, # caseless
listRecordTypes,
attrs,
- ))
- results = opendirectory.queryRecordsWithAttribute_list(
- self.directory,
- query.attribute,
- query.value,
- query.matchType,
- False,
- listRecordTypes,
- attrs,
)
- self.log_debug("opendirectory.queryRecordsWithAttribute_list matched records: %s" % (len(results),))
+ self.log_debug("opendirectory.queryRecordsWithAttributes matched records: %s" % (len(results),))
+
+ # Commented out because this method is not working for email addresses...
+ # TODO: figure out why
+ #
+ # self.log_debug("opendirectory.queryRecordsWithAttribute_list(%r,%r,%r,%r,%r,%r,%r)" % (
+ # self.directory,
+ # query.attribute,
+ # query.value,
+ # query.matchType,
+ # False,
+ # listRecordTypes,
+ # attrs,
+ # ))
+ # results = opendirectory.queryRecordsWithAttribute_list(
+ # self.directory,
+ # query.attribute,
+ # query.value,
+ # query.matchType,
+ # False,
+ # listRecordTypes,
+ # attrs,
+ # )
+ # self.log_debug("opendirectory.queryRecordsWithAttribute_list matched records: %s" % (len(results),))
+
except opendirectory.ODError, ex:
if ex.message[1] == -14140 or ex.message[1] == -14200:
# Unsupported attribute on record - don't fail
@@ -518,7 +535,7 @@
else:
return ()
- for (recordShortName, value) in results:
+ for (recordShortName, value) in results.iteritems():
# Now get useful record info.
recordGUID = value.get(dsattributes.kDS1AttrGeneratedUID)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090427/d0815d86/attachment-0001.html>
More information about the calendarserver-changes
mailing list