[Zope-Checkins] CVS: Zope/lib/python/ZPublisher -
Iterators.py:1.1.4.1
Chris McDonough
chrism at plope.com
Sun Mar 28 06:11:49 EST 2004
Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv2971/lib/python/ZPublisher
Added Files:
Tag: Zope-2_7-branch
Iterators.py
Log Message:
Merge chrism-publishfile-branch. See http://dev.zope.org/Wikis/DevSite/Proposals/FasterStaticContentServing for more information.
=== Added File Zope/lib/python/ZPublisher/Iterators.py ===
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