[Zope3-checkins] CVS: Products3/bugtracker/browser - tracker.py:1.7

Stephan Richter srichter@cosmos.phy.tufts.edu
Mon, 28 Jul 2003 15:45:23 -0400


Update of /cvs-repository/Products3/bugtracker/browser
In directory cvs.zope.org:/tmp/cvs-serv4442/browser

Modified Files:
	tracker.py 
Log Message:
Test for the Batch object.


=== Products3/bugtracker/browser/tracker.py 1.6 => 1.7 ===
--- Products3/bugtracker/browser/tracker.py:1.6	Mon Jul 28 13:13:45 2003
+++ Products3/bugtracker/browser/tracker.py	Mon Jul 28 15:44:48 2003
@@ -244,8 +244,8 @@
         self.start = start
         if len(list) == 0:
             self.start = -1
-        else:
-            assert start < len(list)
+        elif start >= len(list):
+            raise IndexError, 'start index key out of range'
         self.size = size
         self.trueSize = size
         if start+size >= len(list):
@@ -256,14 +256,15 @@
         return self.trueSize
 
     def __getitem__(self, key):
-        assert key < trueSize
+        if key >= self.trueSize:
+            raise IndexError, 'batch index out of range'
         return self.list[self.start+key]
 
     def __iter__(self): 
         return iter(self.list[self.start:self.end+1])
 
-    def __contains__(self, key):
-        return key >= 0 and key < self.__len__()
+    def __contains__(self, item):
+        return item in self.__iter__()
 
     def nextBatch(self):
         start = self.start + self.size