[CalendarServer-changes] [8996] CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav /method/report_addressbook_query.py
source_changes at macosforge.org
source_changes at macosforge.org
Fri Apr 6 16:59:29 PDT 2012
Revision: 8996
http://trac.macosforge.org/projects/calendarserver/changeset/8996
Author: gaya at apple.com
Date: 2012-04-06 16:59:28 -0700 (Fri, 06 Apr 2012)
Log Message:
-----------
fix case where doAddressBookQuery() results do not match is limited
Modified Paths:
--------------
CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/method/report_addressbook_query.py
Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/method/report_addressbook_query.py
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/method/report_addressbook_query.py 2012-04-06 23:07:06 UTC (rev 8995)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/method/report_addressbook_query.py 2012-04-06 23:59:28 UTC (rev 8996)
@@ -159,25 +159,35 @@
def queryDirectoryBackedAddressBook(directoryBackedAddressBook, addressBookFilter):
"""
"""
- results, limited[0] = (yield directoryBackedAddressBook.directory.doAddressBookQuery( addressBookFilter, query, max_number_of_results[0] ))
- for vCardResult in results:
+
+ # doAddressBookQuery() results may not match the filter but be limited.
+ # if that happens, try again with a larger maxResults
+ maxResults = max_number_of_results[0]
+ while True:
+ results, limited[0] = (yield directoryBackedAddressBook.directory.doAddressBookQuery( addressBookFilter, query, maxResults ))
+ for vCardResult in results:
+
+ # match against original filter
+ if filter.match((yield vCardResult.vCard())):
+
+ # Check size of results is within limit
+ checkMaxResults()
+
+ try:
+ yield report_common.responseForHref(request, responses, vCardResult.hRef(), vCardResult, propertiesForResource, query, vcard=(yield vCardResult.vCard()))
+ except ConcurrentModification:
+ # This can happen because of a race-condition between the
+ # time we determine which resources exist and the deletion
+ # of one of these resources in another request. In this
+ # case, we ignore the now missing resource rather
+ # than raise an error for the entire report.
+ log.err("Missing resource during sync: %s" % (vCardResult.hRef(),))
- # match against original filter
- if filter.match((yield vCardResult.vCard())):
+ # query again if no matches and limited
+ if matchcount[0] or not limited[0] or maxResults > config.MaxQueryWithDataResults:
+ break
+ maxResults *= 2
- # Check size of results is within limit
- checkMaxResults()
-
- try:
- yield report_common.responseForHref(request, responses, vCardResult.hRef(), vCardResult, propertiesForResource, query, vcard=(yield vCardResult.vCard()))
- except ConcurrentModification:
- # This can happen because of a race-condition between the
- # time we determine which resources exist and the deletion
- # of one of these resources in another request. In this
- # case, we ignore the now missing resource rather
- # than raise an error for the entire report.
- log.err("Missing resource during sync: %s" % (vCardResult.hRef(),))
-
if not addrresource.isAddressBookCollection():
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120406/5b9365db/attachment.html>
More information about the calendarserver-changes
mailing list