Thanks for the insights. Re. my #2: you suggest caching values or fetch them only on a GET. Ok, so does that mean I create the form up front without the "value=..." clauses, and set the values only when I determine the request is a GET? I'm not sure of the exact sequence here.
Thanks again. On Wednesday, October 31, 2012 4:04:25 PM UTC-6, Niphlod wrote: > > On Wednesday, October 31, 2012 10:08:41 PM UTC+1, MichaelF wrote: >> >> 1. Re. PS2: Thanks for the info on the public functions. Sorry about not >> attaching a complete app; I thought that really wouldn't have been >> reasonable on my part. Also, it requires db access, etc. I'll try to repro >> the problem on a smaller scale. > > > Yep, the point wans't really "tied" to your case, but to all users posting > their controllers claiming misunderstandings and/or uncommon behaviours. > You can contribute to web2py too just allowing "testers" to spend less > time on reproducing, hence replying faster/better with the solution (or the > identification of the claimed bug). > Packing apps is one way, but if you feel compelled to reproduce only one > part of it, you must "trim" it down in a way that's reproducible by others, > or only "structural" errors will be spotted. > Reducing your code to something small and reproducible makes your life > easier too (you become a "tester", grasp what goes on web2py code, and > maybe you end up helping others with the saved time :-P). You can also > pinpoint better the root cause of your behaviour (e.g. are sessions values > saved even if I redirect ? if not, then found a problem, if yes, then it's > something else my controller is trying to do) > > >> >> 2. Re. PS1: Please forgive my ignorance/incompetence. When I build my >> form I have values in it (taken from the db), so building the form at the >> start means I have to go to the db to retrieve those values (as in, >> "value=retVals.subject"). I'm trying to avoid doing that on a POST. Or >> should I build a 'valueless' form at the start, and add values only if I'm >> not handling the POST? >> > > There's no notion of fetching values from db in your code, so I couldn't > guess a reason. > Cache the fetched values if it takes so much to retrieve them (or fetch > them only if request.env.request_method == 'GET'). You are exposing youself > to double submits and XSRF leaving a form without accepts() or process(). > > >> >> 3. Given that your example works fine, what sorts of things should I look >> for in my app that might cause the session to be recreated? >> >> > Try to trim away unnecessary code and reduce until you can't verify the > behaviour anymore (or start from my example, see if it's fine even for you, > then add back your code) > > --

