[Checkins] SVN: zope.file/trunk/src/zope/file/download.py Make it
possible to more easily use the result code
Gary Poster
gary at zope.com
Wed Nov 22 17:26:37 EST 2006
Log message for revision 71278:
Make it possible to more easily use the result code
Changed:
U zope.file/trunk/src/zope/file/download.py
-=-
Modified: zope.file/trunk/src/zope/file/download.py
===================================================================
--- zope.file/trunk/src/zope/file/download.py 2006-11-22 22:18:11 UTC (rev 71277)
+++ zope.file/trunk/src/zope/file/download.py 2006-11-22 22:26:36 UTC (rev 71278)
@@ -47,6 +47,15 @@
zope.interface.implements(
zope.publisher.http.IResult)
+ def getFile(self, context):
+ # This ensures that what's left has no connection to the
+ # application/database; ZODB BLOBs will provide a equivalent
+ # feature once available.
+ f = context.open('rb')
+ res = cStringIO.StringIO(f.read())
+ f.close()
+ return res
+
def __init__(self, context, contentType=None, downloadName=None,
contentDisposition=None):
if not contentType:
@@ -64,13 +73,8 @@
)
self.headers += ("Content-Disposition", contentDisposition),
- # This ensures that what's left has no connection to the
- # application/database; ZODB BLOBs will provide a equivalent
- # feature once available.
- #
- data = context.open("rb").read()
self.headers += ("Content-Length", str(context.size)),
- self.body = bodyIterator(cStringIO.StringIO(data))
+ self.body = bodyIterator(self.getFile(context))
CHUNK_SIZE = 64 * 1024
More information about the Checkins
mailing list