[CalendarServer-changes] [8930] CalendarServer/branches/users/gaya/ldapdirectorybacker

source_changes at macosforge.org source_changes at macosforge.org
Mon Mar 26 16:23:47 PDT 2012


Revision: 8930
          http://trac.macosforge.org/projects/calendarserver/changeset/8930
Author:   gaya at apple.com
Date:     2012-03-26 16:23:47 -0700 (Mon, 26 Mar 2012)
Log Message:
-----------
fix CalDAVTester test address book search query cases with xmldirectorybacker

Modified Paths:
--------------
    CalendarServer/branches/users/gaya/ldapdirectorybacker/conf/auth/accounts-test.xml
    CalendarServer/branches/users/gaya/ldapdirectorybacker/conf/caldavd-test.plist
    CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py
    CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/xmldirectorybacker.py

Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/conf/auth/accounts-test.xml
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/conf/auth/accounts-test.xml	2012-03-26 21:38:03 UTC (rev 8929)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/conf/auth/accounts-test.xml	2012-03-26 23:23:47 UTC (rev 8930)
@@ -106,6 +106,7 @@
     <name>Public %02d</name>
     <first-name>Public</first-name>
     <last-name>%02d</last-name>
+     <email-address>public%02d at example.com</email-address>
   </user>
   <group>
     <uid>group01</uid>

Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/conf/caldavd-test.plist
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/conf/caldavd-test.plist	2012-03-26 21:38:03 UTC (rev 8929)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/conf/caldavd-test.plist	2012-03-26 23:23:47 UTC (rev 8930)
@@ -994,6 +994,30 @@
       <string>English</string>
     </dict>
 
-
+    <!--
+        Directory Address Book
+      -->
+    
+    <!--  Disable Directory Address Book -->
+    <!--
+      <key>DirectoryAddressBook</key>
+      <false/>
+    -->
+    
+    <!-- XML Directory-backed Directory Address Book -->
+    <key>EnableSearchAddressBook</key>
+    <true/>
+    <key>DirectoryAddressBook</key>
+    <dict>
+        <key>Enabled</key>
+        <true/>
+      <key>type</key>
+      <string>twistedcaldav.directory.xmldirectorybacker.XMLDirectoryBackingService</string>
+      <key>params</key>
+      <dict>
+        <key>xmlFile</key>
+        <string>./conf/auth/accounts-test.xml</string>
+      </dict>
+   </dict>
   </dict>
 </plist>

Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py	2012-03-26 21:38:03 UTC (rev 8929)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py	2012-03-26 23:23:47 UTC (rev 8930)
@@ -629,7 +629,8 @@
 
                 if constant:
                     # do the match right now!  Return either all or none.
-                    return( textMatchElement.test([constant,]), [], [] )
+                    #FIXME: match is not implemented in twisteddaldav.query.addressbookqueryfilter.TextMatch so use _match for now
+                    return( textMatchElement._match([constant,]), [], [] )
                 else:
 
                     matchStrings = getMatchStrings(propFilter, textMatchElement.text)
@@ -719,8 +720,10 @@
             allAttrStrings = stringAttrStrs + binaryAttrStrs
                                     
             constant = ABDirectoryQueryResult.constantProperties.get(propFilter.filter_name)
-            if not constant and not allAttrStrings: 
-                return (False, [], [])
+            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)

Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/xmldirectorybacker.py
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/xmldirectorybacker.py	2012-03-26 21:38:03 UTC (rev 8929)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/xmldirectorybacker.py	2012-03-26 23:23:47 UTC (rev 8930)
@@ -209,7 +209,7 @@
                             self.log_debug("recordsForDSFilter: match=%s" % (match.generate(), ))
                             xmlMatchType = {
                                 dsattributes.eDSExact :        "exact",
-                                dsattributes.eDSStartsWith :   "start-with",
+                                dsattributes.eDSStartsWith :   "starts-with",
                                 dsattributes.eDSContains :     "contains",
                             }.get(match.matchType)
                             if not xmlMatchType:
@@ -220,7 +220,7 @@
                             self.log_debug("recordsForDSFilter: fields=%s" % (fields,))
                         
                         # if there were matches, call get records that match
-                        result = set()
+                        result = None
                         if len(fields):
                             operand = "and" if dsFilter.operator == dsquery.expression.AND else "or"
                             self.log_debug("recordsForDSFilter: recordsMatchingFields(fields=%s, operand=%s, recordType=%s)" % (fields, operand, recordType,))
@@ -236,7 +236,9 @@
                             if subresult is None:
                                 returnValue(None)
                             
-                            if dsFilter.operator == dsquery.expression.OR:
+                            if result is None:
+                                result = subresult
+                            elif dsFilter.operator == dsquery.expression.OR:
                                 result = result.union(subresult)
                             else:
                                 result = result.intersection(subresult)
@@ -257,7 +259,9 @@
                 
                 # apply limit
                 if len(xmlDirectoryRecords) > maxRecords:
-                    xmlDirectoryRecords = set(list(xmlDirectoryRecords)[:maxRecords])
+                    #sort so that CalDAVTester can have consistent results when it uses limits
+                    xmlDirectoryRecords = sorted(list(xmlDirectoryRecords), key=lambda x:x.guid)
+                    xmlDirectoryRecords = xmlDirectoryRecords[:maxRecords]
                 self.log_debug("doAddressBookQuery: #xmlDirectoryRecords after max %s" % (len(xmlDirectoryRecords), ))
                    
                 for xmlDirectoryRecord in xmlDirectoryRecords:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120326/3d28017a/attachment-0001.html>


More information about the calendarserver-changes mailing list