After researching the forum and other locations I found the following 
"solution":
the raise HTTP(200) seems to break the running submit code. As suggested 
elsewhere the download should be invoked on another page. So first redirect 
and than start the download.

 I replaced: 
 selectable = [('Download selected PDFs as ZIP',lambda row : 
mapping_multiple(row)), 
                                       ('Download selected as EXCEL',lambda 
row : mapping_multiple_excel(row))
                                      ]
by:
selectable = [('Download selected PDFs as ZIP',lambda row 
:redirect(URL('default', 'downloading',
                                                                            
                   vars=dict(ids=row, 
                                                                            
                             message = 'zipped PDF files',
                                                                            
                             target='make_pdf_zip')))),
                      ('Download selected as EXCEL', lambda row 
:redirect(URL('default', 'downloading',
                                                                            
                   vars=dict(ids=row, 
                                                                            
                             message = 'excel',
                                                                            
                             target='make_excel')))), ]

add a controller function and view

def downloading():
    ids = request.vars['ids']
    target = request.vars['target']
    if ids<>None and ids<>'' and len(ids)<>0:
        return dict(message=T("Downloading reports"), ids=ids, 
target=target)
    return dict(message=T("Nothing to download"), ids=None, target='')

The view downloading.html
{{extend 'layout.html'}}
<h1>Downloading</h1>
{{=message}}<br>
<script>$(function() {
                   {{if ids<>None:}}
                    
window.location.replace("{{=URL('default',target,vars=dict(ids=ids))}}");
                   {{pass}}
                window.setTimeout(function(){
                    window.history.back();
                    }, 2000);
                      });
</script>


and two target functions: 
def make_excel():
    ids = request.vars['ids']
    etc. make the excel file etc.
    raise HTTP(200, buff.getvalue(), **response.headers)

def make_zip_pdf():
   ids = request.vars['ids']
   etc. make the pdfs and zip'm etc.
   raise HTTP(200, buff.getvalue(), **response.headers)

After clicking the appropriate button a new page is shown with the message 
and the file is downloaded. After 2 seconds the previous page is shown.

Not really elegant but it works.  

anybody in for suggestions?

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to