source: OpenRLabs-Git/deploy/rlabs-docker/web2py-rlabs/applications/welcome/views/generic.csv

main
Last change on this file was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100755
File size: 704 bytes
Line 
1{{"""Usage:
2
3  def controller():
4      return {"": db().select(db.thing.ALL)}
5
6And then visit that controller with a .csv extention name
7"""
8}}{{if len(response._vars)==1:}}{{
9# Not yet find a Python 2/3 compatible StringIO pattern,
10# we avoid this solution http://web2py.com/books/default/chapter/29/10/services#CSV
11# Here we buffer the entire csv file instead (it is your controller's job to limit the volume anyway),
12# based on: http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#CSV-one-Table-at-a-time-
13
14content = response._vars[next(iter(response._vars))]
15response.headers['Content-Type'] = 'application/vnd.ms-excel'
16response.write(str(content), escape=False)
17}}{{pass}}
Note: See TracBrowser for help on using the repository browser.