[CalendarServer-changes] [3050] CalendarServer/branches/users/sagen/principal-property-search-3029/ lib-patches/Twisted/twisted.web2.dav.method. report_principal_property_search.patch

source_changes at macosforge.org source_changes at macosforge.org
Wed Sep 24 16:05:05 PDT 2008


Revision: 3050
          http://trac.macosforge.org/projects/calendarserver/changeset/3050
Author:   sagen at apple.com
Date:     2008-09-24 16:05:05 -0700 (Wed, 24 Sep 2008)
Log Message:
-----------
Support caseless and match-type for non-directory-based searches as well

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/principal-property-search-3029/lib-patches/Twisted/twisted.web2.dav.method.report_principal_property_search.patch

Modified: CalendarServer/branches/users/sagen/principal-property-search-3029/lib-patches/Twisted/twisted.web2.dav.method.report_principal_property_search.patch
===================================================================
--- CalendarServer/branches/users/sagen/principal-property-search-3029/lib-patches/Twisted/twisted.web2.dav.method.report_principal_property_search.patch	2008-09-24 22:24:36 UTC (rev 3049)
+++ CalendarServer/branches/users/sagen/principal-property-search-3029/lib-patches/Twisted/twisted.web2.dav.method.report_principal_property_search.patch	2008-09-24 23:05:05 UTC (rev 3050)
@@ -22,7 +22,7 @@
      # Get a single DAV:prop element from the REPORT request body
      propertiesForResource = None
      propElement = None
-@@ -71,9 +77,22 @@
+@@ -71,10 +77,22 @@
          elif child.qname() == (dav_namespace, "property-search"):
              props = child.childOfType(davxml.PropertyContainer)
              props.removeWhitespaceNodes()
@@ -42,11 +42,31 @@
 +            propertySearches.append((props.children, str(match),
 +                caseless, matchType))
      
-+    # TODO: support caseless and matchType
-     def nodeMatch(node, match):
+-    def nodeMatch(node, match):
++    def nodeMatch(node, match, caseless, matchType):
          """
          See if the content of the supplied node matches the supplied text.
-@@ -93,73 +112,156 @@
+         Try to follow the matching guidance in rfc3744 section 9.4.1.
+@@ -85,81 +103,174 @@
+         node.removeWhitespaceNodes()
+         for child in node.children:
+             if isinstance(child, davxml.PCDATAElement):
+-                comp = str(child).lower()
+-                if comp.find(match) != -1:
++                if caseless:
++                    comp = str(child).lower()
++                    match = match.lower()
++                else:
++                    comp = str(child)
++
++                if matchType == "starts-with":
++                    if comp.find(match) == 0:
++                        return True
++                elif comp.find(match) != -1:
+                     return True
++
+             else:
+                 return nodeMatch(child, match)
          else:
              return False
          
@@ -78,7 +98,8 @@
 +                        yield propvalue
 +                        propvalue = propvalue.getResult()
 +                        if propvalue:
-+                            if not nodeMatch(propvalue, match):
++                            if not nodeMatch(propvalue, match, caseless,
++                                matchType):
 +                                yield False
 +                                return
 +                    except HTTPError:
@@ -103,7 +124,7 @@
 +                        yield propvalue
 +                        propvalue = propvalue.getResult()
 +                        if propvalue:
-+                            if nodeMatch(propvalue, match):
++                            if nodeMatch(propvalue, match, caseless, matchType):
 +                                yield True
 +                                return
 +                    except HTTPError:
@@ -249,7 +270,7 @@
                      yield d
                      d = d.getResult()
                      if d:
-@@ -167,18 +269,26 @@
+@@ -167,18 +278,26 @@
                          matchcount += 1
                          if matchcount > max_number_of_matches:
                              raise NumberOfMatchesWithinLimits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080924/8408b801/attachment.html 


More information about the calendarserver-changes mailing list