I'm at a loss.

I have a search view with two different forms. Description of the forms is 
in controller. Each form can select different rows from db and then that 
rows are shown at the bottom of the current view. 
So, the question is how to export received results? I tried to wrote special 
function with arg for this:
*

def export_search_results(res=None, eres=None):
    response.headers['content-type']='text/csv' 
    response.headers['Content-disposition'] = 'attachment; 
filename=export.csv'
    if res is None:
        response,flash = 'None'
    else:
        return '%s\n'%';'.join('id num ves dt 
usr'.split())+'\n'.join([';'.join(map(str,[r.id, r.num, r.ves, r.dt, 
r.usr])) for r in res])
    
if eres is None:
*
        response,flash = 'None'
    else:
        return '%s\n'%';'.join('id num ves dt 
usr'.split())+'\n'.join([';'.join(map(str,[r.id, r.num, r.ves, r.dt, 
r.usr])) for r in eres])

Then in the search view page I wrote the links like that:
*{{for r in results:}}*
*   bla ... bla ... bla ... search results here ...*
*{{pass}}*
{{=A('export to CSV', _href=URL('export_search_results(results)'))}}

But that kind of link doesn't work because of invalid request error. After 
that I don't know how to settle the matter. 
Can anybody help me, please?

Reply via email to