That's not going to work.
Instead of:
*
def export_search_results(res=None, eres=None):
*
You need something like this:
*
def export_search_results():
if request.vars.eres:
r = db(......==eres).select()
return '%s\n'%';'.join...
{{=A('export to CSV', _href=URL('export_search_results',
vars={res=eres.id))}}
So your URL() link is going to call export_search_results and pass it an ID
via a request.var that corresponds to the data. If you haven't saved the
data in memory somehow, you will need to retrieve it again from the DB (or
wherever).
*