[mod_python] streaming tar and/or zip files?

Matthew Dennis mdennis at merfer.net
Fri Jun 29 16:41:26 EDT 2007


This may not be the appropriate list, my apologies if that is indeed the
case...

I need to push from mod_python a file archive of sorts.  Any of tar,
tar.gzor zip will work (I'm also open to other suggestions).  The
requirement is
that I can package several other "files" into it, compressed or not.  I have
no disk to write to and finite memory to deal with but the "files" I'm
outputting are quite large (much larger than can fit in memory), thus I need
to stream them directly out.  The reason I put "files" in quotes is because
they are not really files, but dynamic content that is generated on the
fly.  ZipOutputStream from Java is a example of what I'm talking about if
anyone is familiar with it, as are other such streams.  I don't know the
size of the content until after it is all generated so there is no way to
populate a TarInfo object with the size et cetera and make my dynamic
content look like a file (which it doesn't seem I can do anyway as
gettarinfo() tries to call .fileno() which doesn't exist on any file like
object I would create).

In other words, something like:

output = TarFileStream(someFileObj)

output.addEntry("file_1.txt")
out.write( /*some dynamically generated content */ )
out.write( /*some dynamically generated content */ )
out.write( /*some dynamically generated content */ )

output.addEntry("file_2.txt")
out.write( /*some dynamically generated content */ )
out.write( /*some dynamically generated content */ )
out.write( /*some dynamically generated content */ )

...

output.addEntry("file_N.txt")
out.write( /*some dynamically generated content */ )
out.write( /*some dynamically generated content */ )
out.write( /*some dynamically generated content */ )

output.close()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20070629/b7a4ea17/attachment.html


More information about the Mod_python mailing list