[CalendarServer-changes] [9209] CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav /directory/opendirectorybacker.py
source_changes at macosforge.org
source_changes at macosforge.org
Thu Apr 26 19:48:38 PDT 2012
Revision: 9209
http://trac.macosforge.org/projects/calendarserver/changeset/9209
Author: gaya at apple.com
Date: 2012-04-26 19:48:37 -0700 (Thu, 26 Apr 2012)
Log Message:
-----------
evaluate ParameterFilter and TextMatch filters in one pass
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-04-27 02:38:33 UTC (rev 9208)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py 2012-04-27 02:48:37 UTC (rev 9209)
@@ -48,7 +48,6 @@
from twistedcaldav.config import config
from twistedcaldav.directory.directory import DirectoryService
from twistedcaldav.query import addressbookqueryfilter
-from twistedcaldav.query.addressbookqueryfilter import TextMatch
from twistedcaldav.vcard import Component, Property, vCardProductID
from xmlrpclib import datetime
@@ -833,36 +832,31 @@
# return None to try to match all items if this is the only property filter
return None
- paramFilterElements = [paramFilterElement for paramFilterElement in propFilter.filters if isinstance(paramFilterElement, addressbookqueryfilter.ParameterFilter)]
- textMatchElements = [textMatchElement for textMatchElement in propFilter.filters if isinstance(textMatchElement, addressbookqueryfilter.TextMatch)]
-
#create a textMatchElement for the IsNotDefined qualifier
if isinstance(propFilter.qualifier, addressbookqueryfilter.IsNotDefined):
- textMatchElement = TextMatch(carddavxml.TextMatch.fromString(""))
+ textMatchElement = addressbookqueryfilter.TextMatch(carddavxml.TextMatch.fromString(""))
textMatchElement.negate = True
- textMatchElements += [textMatchElement,]
+ propFilter.filters.append(textMatchElement)
# if only one propFilter, then use filterAllOf as propFilterAllOf to reduce subexpressions and simplify generated query string
- if len(paramFilterElements)+len(textMatchElements) == 1:
+ if len(propFilter.filters) == 1:
propFilterAllOf = filterAllOf
else:
propFilterAllOf = propFilter.propfilter_test == "allof"
propFilterExpressions = None
- for paramFilterElement in paramFilterElements:
- paramFilterExpressions = paramFilterElementExpression(propFilterAllOf, paramFilterElement)
- propFilterExpressions = combineExpressionLists(propFilterExpressions, propFilterAllOf, paramFilterExpressions)
+ for propFilterElement in propFilter.filters:
+ propFilterExpression = None
+ if isinstance(propFilterElement, addressbookqueryfilter.ParameterFilter):
+ propFilterExpression = paramFilterElementExpression(propFilterAllOf, propFilterElement)
+ elif isinstance(propFilterElement, addressbookqueryfilter.TextMatch):
+ propFilterExpression = textMatchElementExpression(propFilterAllOf, propFilterElement)
+ propFilterExpressions = combineExpressionLists(propFilterExpressions, propFilterAllOf, propFilterExpression)
if isinstance(propFilterExpressions, bool) and propFilterAllOf != propFilterExpression:
break
- for textMatchElement in textMatchElements:
- textMatchExpressions = textMatchElementExpression(propFilterAllOf, textMatchElement)
- propFilterExpressions = combineExpressionLists(propFilterExpressions, propFilterAllOf, textMatchExpressions)
- if isinstance(propFilterExpressions, bool) and propFilterAllOf != propFilterExpression:
- break
-
if isinstance(propFilterExpressions, list):
- propFilterExpressions= list(set(propFilterExpressions))
+ propFilterExpressions = list(set(propFilterExpressions))
if propFilterExpressions and (filterAllOf != propFilterAllOf):
propFilterExpressions = [dsquery.expression(dsquery.expression.AND if propFilterAllOf else dsquery.expression.OR , propFilterExpressions)]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120426/796e941c/attachment.html>
More information about the calendarserver-changes
mailing list