Off-hand, I'm not sure of the best approach. I understand wanting to automate cleanup of the db connection, but in this case a manual mechanism would be useful.
If the controller could get a db connection manually, it could then return an iterator that closes the connection on the last value, and on error. Perhaps this is already possible. Can the controller manually get a db connection from the underlying db or connection pool? To make it slightly less error-prone, web2py could provide an iterable wrapper that opens & closes the db connection, catching errors. On Friday, December 4, 2015 at 3:29:15 PM UTC-8, Anthony wrote: > > Yes, I see this is tricky because web2py closes the database connection > once the response is returned, yet if you return a generator that is > iterating through database queries, the connection must remain open. Do you > have a suggestion for how this can be achieved (i.e., something the > framework could do differently)? > > Anthony > > On Friday, December 4, 2015 at 3:42:00 PM UTC-5, Brian Craft wrote: >> >> Ah, I see. I'm not sure that helps me, because I want the browser to >> download the result. The problem from the UX perspective is this huge delay >> between when the user clicks the download button & when the browser brings >> up the "save" dialog. That delay is determined by when the server sends the >> headers for the response. Because of the delay, it looks like the button >> isn't working, and the user may click on it several more times. There's no >> place to inject an ajax query in the built-in browser 'download' >> functionality. >> >> There are various horrible work-arounds, like using cookies to determine >> when the download has started. It's tempting to try writing a controller >> that creates a thread which submits another request, where the db query >> runs. >> >> Perhaps there should be a link to LOAD in the view docs, since it's a >> view expression. >> >> On Thursday, December 3, 2015 at 4:27:19 PM UTC-8, Anthony wrote: >>> >>> On Thursday, December 3, 2015 at 5:37:51 PM UTC-5, Brian Craft wrote: >>>> >>>> I don't know what this means. >>>> >>> >>> He's saying to load a parent page (that does not run the query or return >>> any data), and once the parent page has loaded, then request the data via >>> Ajax. >>> >>> >>>> Also, I can't find docs for LOAD(). >>>> >>> >>> >>> http://web2py.com/books/default/chapter/29/12/components-and-plugins#Components--LOAD-and-Ajax >>> >>> Anthony >>> >> -- 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.