I get the same result with the posted function, albeit your nuances 
appreciated.

To be thorough, I'll repost the updated function.

def download_that():

    import zipfile

    import cStringIO

    import contenttype as c

    vars = request.vars

    tempfile = cStringIO.StringIO()

    temparchive = zipfile.ZipFile(tempfile, 'w', zipfile.ZIP_DEFLATED)

    

    fileIDs = vars.values()

    try:

        for file_id in fileIDs:

            file = db.files[file_id].file

            fileLoc = db.files.file.retrieve_file_properties(file)['path'] 
+ '/' + file

            temparchive.writestr(db.files[file_id].file_name, open(fileLoc, 
'rb').read())

    

    finally:

        temparchive.close() #writes 

        response.headers['Content-Disposition'] = 
'attachment;filename=files.zip'

        response.headers['Content-Type'] = 'application/zip'

        rtn = tempfile.getvalue()

        tempfile.close()

    return rtn

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to