Hi all

Following the example in the book 
<http://web2py.com/books/default/chapter/29/10/services?search=export_to_csv>, 
I can display the contents of a database table (ie the list of animals in 
the book example) on the screen and add a button to download the data to a 
CSV file.

However, changing the model definition to use a reference table:

db.define_table('genus',
    Field('description'),
    format = '%(description)s')

db.define_table('animal',
    Field('species'),
    Field('genus', 'reference genus'))

and the controller to use the represent() method:

def animal():
    animals = db().select(db.animal.ALL).render()
    return dict(animals=animals)

the view continues to work fine but the export_to_csv button now raises an 
error:

<type 'exceptions.AttributeError'> 'generator' object has no attribute 
'export_to_csv_file'

The ability to export data to csv is important for my application. 

So my question is - is there a (simple) way to export a generator object to 
a csv file, or is it better to rely on table joins in the DAL rather than 
the render function?

Any suggestions much appreciated!

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to