[CalendarServer-changes] [8942] CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav /directory/opendirectorybacker.py
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 27 16:54:02 PDT 2012
Revision: 8942
http://trac.macosforge.org/projects/calendarserver/changeset/8942
Author: gaya at apple.com
Date: 2012-03-27 16:54:02 -0700 (Tue, 27 Mar 2012)
Log Message:
-----------
fix handling of unmapped query filters
Modified Paths:
--------------
CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py
Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py 2012-03-27 23:53:26 UTC (rev 8941)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py 2012-03-27 23:54:02 UTC (rev 8942)
@@ -718,13 +718,12 @@
else:
stringAttrStrs.append(attr)
allAttrStrings = stringAttrStrs + binaryAttrStrs
+ if not allAttrStrings:
+ # not AllAttrStrings means propFilter.filter_name is not mapped
+ # return None to try to match all items if this is the only property filter
+ return (None, [], [])
constant = ABDirectoryQueryResult.constantProperties.get(propFilter.filter_name)
- if not constant and not allAttrStrings:
- # not AllAttrStrings means propFilter.filter_name is not mapped
- # return True to try to match all results later on
- return (not constant, [], [])
-
if propFilter.qualifier and isinstance(propFilter.qualifier, addressbookqueryfilter.IsNotDefined):
return definedExpression(False, filterAllOf, propFilter.filter_name, constant, queryAttributes, allAttrStrings)
@@ -772,18 +771,26 @@
@param propFilters: the C{list} of L{ComponentFilter} elements.
@return: (needsAllRecords, espressionAttributes, expression) tuple
"""
- needsAllRecords = filterAllOf
+ needsAllRecords = None
attributes = []
expressions = []
for propFilter in propFilters:
propNeedsAllRecords, propExpressionAttributes, propExpression = propFilterExpression(filterAllOf, propFilter)
- if filterAllOf:
- needsAllRecords &= propNeedsAllRecords
- else:
- needsAllRecords |= propNeedsAllRecords
+ if needsAllRecords is None:
+ needsAllRecords = propNeedsAllRecords
+ elif propNeedsAllRecords is not None:
+ if filterAllOf:
+ needsAllRecords &= propNeedsAllRecords
+ else:
+ needsAllRecords |= propNeedsAllRecords
attributes += propExpressionAttributes
expressions += propExpression
+ # propFilterExpression()'s returned propNeedsAllRecords is only None if a propFilter.filter_name is not not mapped
+ # needsAllRecords is None if there was only one propFilter that returned None
+ # set needsAllRecords True in the case
+ if needsAllRecords is None:
+ needsAllRecords = not filterAllOf
if len(expressions) > 1:
expr = dsquery.expression(dsquery.expression.AND if filterAllOf else dsquery.expression.OR , list(set(expressions))) # remove duplicates
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120327/41c806e3/attachment.html>
More information about the calendarserver-changes
mailing list