<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12113] twext/trunk/twext/who</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/12113">12113</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2013-12-16 16:01:37 -0800 (Mon, 16 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>More OD cleanup</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#twexttrunktwextwhoexpressionpy">twext/trunk/twext/who/expression.py</a></li>
<li><a href="#twexttrunktwextwhoopendirectoryodframeworkpy">twext/trunk/twext/who/opendirectory/odframework.py</a></li>
<li><a href="#twexttrunktwextwhoopendirectoryservicepy">twext/trunk/twext/who/opendirectory/service.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="twexttrunktwextwhoexpressionpy"></a>
<div class="modfile"><h4>Modified: twext/trunk/twext/who/expression.py (12112 => 12113)</h4>
<pre class="diff"><span>
<span class="info">--- twext/trunk/twext/who/expression.py        2013-12-16 22:37:53 UTC (rev 12112)
+++ twext/trunk/twext/who/expression.py        2013-12-17 00:01:37 UTC (rev 12113)
</span><span class="lines">@@ -84,8 +84,20 @@
</span><span class="cx">     contains = NamedConstant()
</span><span class="cx">     contains.description = u&quot;contains&quot;
</span><span class="cx"> 
</span><ins>+    lessThan = NamedConstant()
+    lessThan.description = u&quot;less than&quot;
</ins><span class="cx"> 
</span><ins>+    greaterThan = NamedConstant()
+    greaterThan.description = u&quot;greater than&quot;
</ins><span class="cx"> 
</span><ins>+    lessThanOrEqualTo = NamedConstant()
+    lessThanOrEqualTo.description = u&quot;less than or equal to&quot;
+
+    greaterThanOrEqualTo = NamedConstant()
+    greaterThanOrEqualTo.description = u&quot;greater than or equal to&quot;
+
+
+
</ins><span class="cx"> class MatchFlags(Flags):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Match expression flags.
</span></span></pre></div>
<a id="twexttrunktwextwhoopendirectoryodframeworkpy"></a>
<div class="modfile"><h4>Modified: twext/trunk/twext/who/opendirectory/odframework.py (12112 => 12113)</h4>
<pre class="diff"><span>
<span class="info">--- twext/trunk/twext/who/opendirectory/odframework.py        2013-12-16 22:37:53 UTC (rev 12112)
+++ twext/trunk/twext/who/opendirectory/odframework.py        2013-12-17 00:01:37 UTC (rev 12113)
</span><span class="lines">@@ -1,8 +1,10 @@
</span><span class="cx"> import objc as _objc
</span><span class="cx"> 
</span><del>-__bundle__ = _objc.initFrameworkWrapper(&quot;OpenDirectory&quot;,
</del><ins>+__bundle__ = _objc.initFrameworkWrapper(
+    &quot;OpenDirectory&quot;,
</ins><span class="cx">     frameworkIdentifier=&quot;com.apple.OpenDirectory&quot;,
</span><span class="cx">     frameworkPath=_objc.pathForFramework(
</span><del>-    &quot;/System/Library/Frameworks/OpenDirectory.framework&quot;),
-    globals=globals())
-
</del><ins>+        &quot;/System/Library/Frameworks/OpenDirectory.framework&quot;
+    ),
+    globals=globals()
+)
</ins></span></pre></div>
<a id="twexttrunktwextwhoopendirectoryservicepy"></a>
<div class="modfile"><h4>Modified: twext/trunk/twext/who/opendirectory/service.py (12112 => 12113)</h4>
<pre class="diff"><span>
<span class="info">--- twext/trunk/twext/who/opendirectory/service.py        2013-12-16 22:37:53 UTC (rev 12112)
+++ twext/trunk/twext/who/opendirectory/service.py        2013-12-17 00:01:37 UTC (rev 12113)
</span><span class="lines">@@ -46,7 +46,6 @@
</span><span class="cx"> from twext.who.expression import MatchExpression, MatchType, MatchFlags
</span><span class="cx"> from twext.who.util import iterFlags, ConstantsContainer
</span><span class="cx"> 
</span><del>-import dsattributes
</del><span class="cx"> from opendirectory import (
</span><span class="cx">     ODError, odInit,
</span><span class="cx">     getNodeAttributes,
</span><span class="lines">@@ -71,25 +70,39 @@
</span><span class="cx"> #
</span><span class="cx"> 
</span><span class="cx"> class FieldName(Names):
</span><ins>+    searchPath = NamedConstant()
+    searchPath.description = &quot;search path&quot;
+    searchPath.multiValue = False
+
</ins><span class="cx">     metaNodeLocation = NamedConstant()
</span><span class="cx">     metaNodeLocation.description = &quot;source OD node&quot;
</span><span class="cx">     metaNodeLocation.multiValue = False
</span><span class="cx"> 
</span><ins>+    metaRecordName = NamedConstant()
+    metaRecordName.description = &quot;meta record name&quot;
+    metaRecordName.multiValue = False
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx"> #
</span><del>-# Constants
</del><ins>+# OD Constants
</ins><span class="cx"> #
</span><span class="cx"> 
</span><ins>+class ODSearchPath(Values):
+    local = ValueConstant(&quot;/Local/Default&quot;)
+    search = ValueConstant(&quot;/Search&quot;)
+
+
+
</ins><span class="cx"> class ODRecordType(Values):
</span><del>-    user = ValueConstant(dsattributes.kDSStdRecordTypeUsers)
</del><ins>+    user = ValueConstant(&quot;dsRecTypeStandard:Users&quot;)
</ins><span class="cx">     user.recordType = BaseRecordType.user
</span><span class="cx"> 
</span><del>-    group = ValueConstant(dsattributes.kDSStdRecordTypeGroups)
</del><ins>+    group = ValueConstant(&quot;dsRecTypeStandard:Groups&quot;)
</ins><span class="cx">     group.recordType = BaseRecordType.group
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @classmethod
</span><del>-    def recordTypeForRecordType(cls, recordType):
</del><ins>+    def fromRecordType(cls, recordType):
</ins><span class="cx">         if not hasattr(cls, &quot;_recordTypeByRecordType&quot;):
</span><span class="cx">             cls._recordTypeByRecordType = dict((
</span><span class="cx">                 (recordType.recordType, recordType)
</span><span class="lines">@@ -101,30 +114,38 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> class ODAttribute(Values):
</span><del>-    recordType = ValueConstant(dsattributes.kDSNAttrRecordType)
</del><ins>+    searchPath = ValueConstant(&quot;dsAttrTypeStandard:SearchPath&quot;)
+    searchPath.fieldName = FieldName.searchPath
+
+    recordType = ValueConstant(&quot;dsAttrTypeStandard:RecordType&quot;)
</ins><span class="cx">     recordType.fieldName = BaseFieldName.recordType
</span><span class="cx"> 
</span><del>-    uid = ValueConstant(dsattributes.kDS1AttrGeneratedUID)
</del><ins>+    uid = ValueConstant(&quot;dsAttrTypeStandard:GeneratedUID&quot;)
</ins><span class="cx">     uid.fieldName = BaseFieldName.uid
</span><span class="cx"> 
</span><del>-    guid = ValueConstant(dsattributes.kDS1AttrGeneratedUID)
</del><ins>+    guid = ValueConstant(&quot;dsAttrTypeStandard:GeneratedUID&quot;)
</ins><span class="cx">     guid.fieldName = BaseFieldName.guid
</span><span class="cx"> 
</span><del>-    shortName = ValueConstant(dsattributes.kDSNAttrRecordName)
</del><ins>+    shortName = ValueConstant(&quot;dsAttrTypeStandard:RecordName&quot;)
</ins><span class="cx">     shortName.fieldName = BaseFieldName.shortNames
</span><span class="cx"> 
</span><del>-    fullName = ValueConstant(dsattributes.kDS1AttrDistinguishedName)
</del><ins>+    fullName = ValueConstant(&quot;dsAttrTypeStandard:RealName&quot;)
</ins><span class="cx">     fullName.fieldName = BaseFieldName.fullNames
</span><span class="cx"> 
</span><del>-    emailAddress = ValueConstant(dsattributes.kDSNAttrEMailAddress)
</del><ins>+    emailAddress = ValueConstant(&quot;dsAttrTypeStandard:EMailAddress&quot;)
</ins><span class="cx">     emailAddress.fieldName = BaseFieldName.emailAddresses
</span><span class="cx"> 
</span><del>-    metaNodeLocation = ValueConstant(dsattributes.kDSNAttrMetaNodeLocation)
</del><ins>+    metaNodeLocation = ValueConstant(
+        &quot;dsAttrTypeStandard:AppleMetaNodeLocation&quot;
+    )
</ins><span class="cx">     metaNodeLocation.fieldName = FieldName.metaNodeLocation
</span><span class="cx"> 
</span><ins>+    metaRecordName = ValueConstant(&quot;dsAttrTypeStandard:AppleMetaRecordName&quot;)
+    metaRecordName.fieldName = FieldName.metaRecordName
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">     @classmethod
</span><del>-    def attributeForFieldName(cls, fieldName):
</del><ins>+    def fromFieldName(cls, fieldName):
</ins><span class="cx">         if not hasattr(cls, &quot;_attributesByFieldName&quot;):
</span><span class="cx">             cls._attributesByFieldName = dict((
</span><span class="cx">                 (attribute.fieldName, attribute)
</span><span class="lines">@@ -137,21 +158,34 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> class ODMatchType(Values):
</span><del>-    equals = ValueConstant(dsattributes.eDSExact)
</del><ins>+    equals = ValueConstant(0x2001)
</ins><span class="cx">     equals.matchType = MatchType.equals
</span><span class="cx"> 
</span><del>-    startsWith = ValueConstant(dsattributes.eDSStartsWith)
</del><ins>+    startsWith = ValueConstant(0x2002)
</ins><span class="cx">     startsWith.matchType = MatchType.startsWith
</span><span class="cx"> 
</span><del>-    endsWith = ValueConstant(dsattributes.eDSEndsWith)
</del><ins>+    endsWith = ValueConstant(0x2003)
</ins><span class="cx">     endsWith.matchType = MatchType.endsWith
</span><span class="cx"> 
</span><del>-    contains = ValueConstant(dsattributes.eDSContains)
</del><ins>+    contains = ValueConstant(0x2004)
</ins><span class="cx">     contains.matchType = MatchType.contains
</span><span class="cx"> 
</span><ins>+    lessThan = ValueConstant(0x2005)
+    lessThan.matchType = MatchType.lessThan
</ins><span class="cx"> 
</span><ins>+    greaterThan = ValueConstant(0x2006)
+    greaterThan.matchType = MatchType.greaterThan
+
+    lessThanOrEqualTo = ValueConstant(0x2007)
+    lessThanOrEqualTo.matchType = MatchType.lessThanOrEqualTo
+
+    greaterThanOrEqualTo = ValueConstant(0x2008)
+    greaterThanOrEqualTo.matchType = MatchType.greaterThanOrEqualTo
+
+
+
</ins><span class="cx">     @classmethod
</span><del>-    def matchTypeForMatchType(cls, matchType):
</del><ins>+    def fromMatchType(cls, matchType):
</ins><span class="cx">         if not hasattr(cls, &quot;_matchTypeByMatchType&quot;):
</span><span class="cx">             cls._matchTypeByMatchType = dict((
</span><span class="cx">                 (matchType.matchType, matchType)
</span><span class="lines">@@ -178,7 +212,7 @@
</span><span class="cx">     ))
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def __init__(self, nodeName=&quot;/Search&quot;):
</del><ins>+    def __init__(self, nodeName=ODSearchPath.search.value):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         @param nodeName: the OpenDirectory node to query against.
</span><span class="cx">         @type nodeName: bytes
</span><span class="lines">@@ -222,17 +256,17 @@
</span><span class="cx">         it specially.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         if not hasattr(self, &quot;_localNode&quot;):
</span><del>-            if self.nodeName == &quot;/Search&quot;:
</del><ins>+            if self.nodeName == ODSearchPath.search.value:
</ins><span class="cx">                 result = getNodeAttributes(
</span><del>-                    self.node, &quot;/Search&quot;,
-                    (dsattributes.kDS1AttrSearchPath,)
</del><ins>+                    self.node, ODSearchPath.search.value,
+                    (ODAttribute.searchPath.value,)
</ins><span class="cx">                 )
</span><span class="cx">                 if (
</span><del>-                    &quot;/Local/Default&quot; in
-                    result[dsattributes.kDS1AttrSearchPath]
</del><ins>+                    ODSearchPath.local.value in
+                    result[ODAttribute.searchPath.value]
</ins><span class="cx">                 ):
</span><span class="cx">                     try:
</span><del>-                        self._localNode = odInit(&quot;/Local/Default&quot;)
</del><ins>+                        self._localNode = odInit(ODSearchPath.local.value)
</ins><span class="cx">                     except ODError, e:
</span><span class="cx">                         self.log.error(
</span><span class="cx">                             &quot;Failed to open local node: {error}}&quot;,
</span><span class="lines">@@ -242,7 +276,7 @@
</span><span class="cx">                 else:
</span><span class="cx">                     self._localNode = None
</span><span class="cx"> 
</span><del>-            elif self.nodeName == &quot;/Local/Default&quot;:
</del><ins>+            elif self.nodeName == ODSearchPath.local.value:
</ins><span class="cx">                 self._localNode = self.node
</span><span class="cx"> 
</span><span class="cx">             else:
</span><span class="lines">@@ -255,7 +289,7 @@
</span><span class="cx">         if not isinstance(expression, MatchExpression):
</span><span class="cx">             raise TypeError(expression)
</span><span class="cx"> 
</span><del>-        matchType = ODMatchType.matchTypeForMatchType(expression.matchType)
</del><ins>+        matchType = ODMatchType.fromMatchType(expression.matchType)
</ins><span class="cx">         if matchType is None:
</span><span class="cx">             raise QueryNotSupportedError(
</span><span class="cx">                 &quot;Unknown match type: {0}&quot;.format(matchType)
</span><span class="lines">@@ -270,7 +304,7 @@
</span><span class="cx">         else:
</span><span class="cx">             results = queryRecordsWithAttribute_list(
</span><span class="cx">                 self.node,
</span><del>-                ODAttribute.attributeForFieldName(expression.fieldName).value,
</del><ins>+                ODAttribute.fromFieldName(expression.fieldName).value,
</ins><span class="cx">                 expression.fieldValue.encode(&quot;utf-8&quot;),
</span><span class="cx">                 matchType.value,
</span><span class="cx">                 caseInsensitive,
</span><span class="lines">@@ -297,8 +331,8 @@
</span><span class="cx">             fields = {}
</span><span class="cx"> 
</span><span class="cx">             for (key, value) in attributes.iteritems():
</span><del>-                if key == &quot;dsAttrTypeStandard:AppleMetaRecordName&quot;:
-                    # We get this even though we did not ask for it...
</del><ins>+                if key == FieldName.metaRecordName:
+                    # We get this field even though we did not ask for it...
</ins><span class="cx">                     continue
</span><span class="cx"> 
</span><span class="cx">                 try:
</span></span></pre>
</div>
</div>

</body>
</html>