you can pass a StringIO instance instead of the open(filename, 'rb') .... 
To avoid the double-pass just create the csv as a StringIO stream and 
insert it directly into the table with the db.tablename.field.store() as 
the example you posted: web2py will save the file into the uploads/ folder 
and no problem with that.

Untested example: assuming in your "generatecsv" function has something 
like....
destination = open('path_to_file', 'wb')
writer = csv.writer(destination)
writer.writerow(['a', 'row'])
destination.close()

you can do instead
from cStringIO import StringIO
destination = StringIO()
writer = csv.writer(destination)
writer.writerow(['a', 'row'])
db.reportcsv.insert(csvfile=db.reportcsv.csvfile.store(destination,'path_to_file'),reportname='report_1')

-- 

--- 
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/groups/opt_out.


Reply via email to