I solved my problem. Part of me wants to just leave it at that. But I come here to teach as well as learn, and this is definitely a "teaching moment" for web2py developers.
The code I posted before was without error. The problem occurred because it was not the only code in the controller. Here is the complete example from the web page: def reg_getfile(): from datetime import datetime as dt from copy import copy if db(db.download_group).isempty(): init_download_groups_table() if session.idset: rset = session.idset session.idclear = copy(rset) now = dt.today() elif request.vars.modified_on: dbrs, dbre = db.reg_swim, db.reg_edit rows = db((dbre.id_regswim==dbrs.id)&(dbre.modified_on==request.vars.modified_on)).select(dbre.id) rset = set([r.id for r in rows]) now = dt.strptime(request.vars.modified_on,'%Y-%m-%d %H:%M:%S') else: return '' return _reg_getfile(now, rset) def _reg_getfile(now,idset): from regexport import generate_regfile from cStringIO import StringIO buf = StringIO() generate_regfile(idset, buf) buf.seek(0) fname = 'reg-%s.sd3'%now.strftime('%y%m%d-%H%M%S') response.headers['Content-Type']='application/sd3' response.headers['Content-Disposition']='attachment; filename=%s'%fname return response.stream(buf) The second method, _reg_getfile() (with the underscore) is what we poured over before. The problem was that it was not the method called directly by the link. The method reg_getfile() (no underscore) is called first. It examines some vars, does a database lookup for the ids of affected rows, and then calls the underscore method. And here is where the problem lies: return _reg_getfile(now,rset) *The code that DOESN'T work lacks the little "return" keyword.* ARRRRGH! I am not an inexperienced Python programmer. It's not that I'm just careless. It's the kind of stupid little error that can sideline anybody, no matter how much code you're written. It's pernicious because everything "seems" to work perfectly. You can stop it almost anywhere and everything looks fine. So let my stupidity be a cautionary tale. When something like this happens to you, you'll solve it quicker if you make these assumptions: 1. It's not the fault of the platform. web2py works just fine. 2. It's not a bug in Python. The chances of finding a bug in Python are probably less than being hit by a meteor. Not because it doesn't have any but because there are so many users that someone else found it already. 3. If it worked before in any fashion -- WHAT CHANGED? In my case I split one method into two. 4. Don't be afraid to step thru the debugger into code you don't know. You'll learn more and eventually find your answer. 5. And last, "always make new mistakes." I like that one. Joe -- 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.