[CalendarServer-changes] [12123] twext/trunk/twext/who
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:20:08 PDT 2014
Revision: 12123
http://trac.calendarserver.org//changeset/12123
Author: sagen at apple.com
Date: 2013-12-17 14:30:35 -0800 (Tue, 17 Dec 2013)
Log Message:
-----------
Add a constant for the 'compound' match type, and have the script do both match expression and compound expression
Modified Paths:
--------------
twext/trunk/twext/who/expression.py
twext/trunk/twext/who/opendirectory/service.py
Modified: twext/trunk/twext/who/expression.py
===================================================================
--- twext/trunk/twext/who/expression.py 2013-12-17 22:15:26 UTC (rev 12122)
+++ twext/trunk/twext/who/expression.py 2013-12-17 22:30:35 UTC (rev 12123)
@@ -96,8 +96,11 @@
greaterThanOrEqualTo = NamedConstant()
greaterThanOrEqualTo.description = u"greater than or equal to"
+ compound = NamedConstant()
+ compound.description = u"compound expression"
+
class MatchFlags(Flags):
"""
Match expression flags.
Modified: twext/trunk/twext/who/opendirectory/service.py
===================================================================
--- twext/trunk/twext/who/opendirectory/service.py 2013-12-17 22:15:26 UTC (rev 12122)
+++ twext/trunk/twext/who/opendirectory/service.py 2013-12-17 22:30:35 UTC (rev 12123)
@@ -197,6 +197,8 @@
greaterThanOrEqualTo = ValueConstant(0x2008)
greaterThanOrEqualTo.matchType = MatchType.greaterThanOrEqualTo
+ compound = ValueConstant(0x210B)
+ compound.matchType = MatchType.compound
@classmethod
def fromMatchType(cls, matchType):
@@ -391,7 +393,7 @@
self.node,
recordTypes,
None,
- 0x210B, # kODMatchCompoundExpression
+ ODMatchType.compound.value,
queryString,
attributes,
maxResults,
@@ -615,10 +617,36 @@
)
for shortName in sys.argv:
- matchMorgen = MatchExpression(
+ print("=" * 80)
+ matchExpression = MatchExpression(
service.fieldName.shortNames, shortName,
matchType=MatchType.equals,
)
- for record in service.recordsFromExpression(matchMorgen):
+ queryString = service._queryStringFromExpression(matchExpression)
+ print("{name} via MatchExpression using query {query}".format(
+ name=shortName, query=queryString))
+ for record in service.recordsFromExpression(matchExpression):
print("*" * 80)
print(record.description())
+
+ print("=" * 80)
+
+ compoundExpression = CompoundExpression(
+ [
+ MatchExpression(
+ service.fieldName.shortNames, shortName,
+ matchType=MatchType.contains
+ ),
+ MatchExpression(
+ service.fieldName.emailAddresses, shortName,
+ matchType=MatchType.contains
+ ),
+ ],
+ Operand.OR
+ )
+ queryString = service._queryStringFromExpression(compoundExpression)
+ print("{name} via CompoundExpression using query {query}".format(
+ name=shortName, query=queryString))
+ for record in service.recordsFromExpression(compoundExpression):
+ print("*" * 80)
+ print(record.description())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/7741b282/attachment.html>
More information about the calendarserver-changes
mailing list