[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - Iterators.py:1.2

Chris McDonough chrism at plope.com
Sun Mar 28 06:13:26 EST 2004


Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv5691/lib/python/ZPublisher

Added Files:
	Iterators.py 
Log Message:
Merge chrism-publishfile-branch.  See http://dev.zope.org/Wikis/DevSite/Proposals/FasterStaticContentServing for more information.


=== Zope/lib/python/ZPublisher/Iterators.py 1.1 => 1.2 ===
--- /dev/null	Sun Mar 28 06:13:26 2004
+++ Zope/lib/python/ZPublisher/Iterators.py	Sun Mar 28 06:12:55 2004
@@ -0,0 +1,27 @@
+from Interface import Interface
+
+class IStreamIterator(Interface):
+    def next(self):
+        """
+        Return a sequence of bytes out of the bytestream, or raise
+        StopIeration if we've reached the end of the bytestream.
+        """
+class filestream_iterator(file):
+    """
+    a file subclass which implements an iterator that returns a
+    fixed-sized sequence of bytes.
+    """
+
+    __implements__ = (IStreamIterator,)
+
+    def __init__(self, name, mode='r', bufsize=-1, streamsize=1<<16):
+        file.__init__(self, name, mode, bufsize)
+        self.streamsize = streamsize
+
+    def next(self):
+        data = self.read(self.streamsize)
+        if not data:
+            raise StopIteration
+        return data
+    
+    




More information about the Zope-Checkins mailing list