[CalendarServer-changes] [3655] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Feb 10 10:46:41 PST 2009


Revision: 3655
          http://trac.macosforge.org/projects/calendarserver/changeset/3655
Author:   cdaboo at apple.com
Date:     2009-02-10 10:46:39 -0800 (Tue, 10 Feb 2009)
Log Message:
-----------
Make sure test accounts include an email address so that cu-address searching works.
Make sure the default record matching (query) is able to handle multi-valued attributes.

Modified Paths:
--------------
    CalendarServer/trunk/conf/auth/accounts-test.xml
    CalendarServer/trunk/twistedcaldav/directory/directory.py

Modified: CalendarServer/trunk/conf/auth/accounts-test.xml
===================================================================
--- CalendarServer/trunk/conf/auth/accounts-test.xml	2009-02-10 16:56:24 UTC (rev 3654)
+++ CalendarServer/trunk/conf/auth/accounts-test.xml	2009-02-10 18:46:39 UTC (rev 3655)
@@ -43,6 +43,7 @@
     <name>User %02d</name>
     <first-name>User</first-name>
     <last-name>%02d</last-name>
+    <email-address>user%02d at example.com</email-address>
     <cuaddr>mailto:user%02d at example.com</cuaddr>
   </user>
   <user repeat="10">

Modified: CalendarServer/trunk/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/directory.py	2009-02-10 16:56:24 UTC (rev 3654)
+++ CalendarServer/trunk/twistedcaldav/directory/directory.py	2009-02-10 18:46:39 UTC (rev 3655)
@@ -28,6 +28,7 @@
 ]
 
 import sys
+import types
 
 from zope.interface import implements
 
@@ -181,21 +182,31 @@
         # service
 
         def fieldMatches(fieldValue, value, caseless, matchType):
-            if caseless:
-                fieldValue = fieldValue.lower()
-                value = value.lower()
+            if fieldValue is None:
+                return False
+            elif type(fieldValue) in types.StringTypes:
+                fieldValue = (fieldValue,)
+            
+            for testValue in fieldValue:
+                if caseless:
+                    testValue = testValue.lower()
+                    value = value.lower()
+    
+                if matchType == 'starts-with':
+                    if testValue.startswith(value):
+                        return True
+                elif matchType == 'contains':
+                    try:
+                        _ignore_discard = testValue.index(value)
+                        return True
+                    except ValueError:
+                        pass
+                else: # exact
+                    if testValue == value:
+                        return True
+                    
+            return False
 
-            if matchType == 'starts-with':
-                return fieldValue.startswith(value)
-            elif matchType == 'contains':
-                try:
-                    discard = fieldValue.index(value)
-                    return True
-                except ValueError:
-                    return False
-            else: # exact
-                return fieldValue == value
-
         def recordMatches(record):
             if operand == "and":
                 for fieldName, value, caseless, matchType in fields:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090210/9dc09c53/attachment-0001.html>


More information about the calendarserver-changes mailing list