[Zope3-checkins] SVN: Zope3/trunk/ Fixed bug 405, http://www.zope.org/Collectors/Zope3-dev/405

Jim Fulton jim at zope.com
Sun Nov 13 12:32:27 EST 2005


Log message for revision 40083:
  Fixed bug 405, http://www.zope.org/Collectors/Zope3-dev/405
  Needed check for common bug when calling apply on field indexes.
  

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/index/field/README.txt
  U   Zope3/trunk/src/zope/index/field/index.py

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2005-11-13 17:11:09 UTC (rev 40082)
+++ Zope3/trunk/doc/CHANGES.txt	2005-11-13 17:32:27 UTC (rev 40083)
@@ -154,6 +154,9 @@
 
     Bug Fixes
 
+      - Fixed bug 405, http://www.zope.org/Collectors/Zope3-dev/405
+        Needed check for common bug when calling apply on field indexes.
+
       - Fixed bug 402, http://www.zope.org/Collectors/Zope3-dev/402
         classImplements after classImplementsOnly lost the interfaces
         declated in classImplementsOnly.

Modified: Zope3/trunk/src/zope/index/field/README.txt
===================================================================
--- Zope3/trunk/src/zope/index/field/README.txt	2005-11-13 17:11:09 UTC (rev 40082)
+++ Zope3/trunk/src/zope/index/field/README.txt	2005-11-13 17:32:27 UTC (rev 40083)
@@ -26,6 +26,15 @@
     >>> index.apply((30, 70))
     IFSet([3, 4, 5, 7, 8])
 
+A common mistake is to pass a single value.  If anything other than a 
+tw-tuple is passed, a type error is raised:
+
+    >>> index.apply('hi')
+    Traceback (most recent call last):
+    ...
+    TypeError: ('two-length tuple expected', 'hi')
+
+
 Open-ended ranges can be provided by provinding None as an end point:
 
     >>> index.apply((30, None))

Modified: Zope3/trunk/src/zope/index/field/index.py
===================================================================
--- Zope3/trunk/src/zope/index/field/index.py	2005-11-13 17:11:09 UTC (rev 40082)
+++ Zope3/trunk/src/zope/index/field/index.py	2005-11-13 17:32:27 UTC (rev 40083)
@@ -96,4 +96,6 @@
         self._num_docs.change(-1)
 
     def apply(self, query):
+        if len(query) != 2 or not isinstance(query, tuple):
+            raise TypeError("two-length tuple expected", query)
         return multiunion(self._fwd_index.values(*query))        



More information about the Zope3-Checkins mailing list