Hello again, well, after an entire day (about 12 hours) around this, i just made a final test with a controler and view something like:
<img alt="1" src="{{=URL(r=request,f='get_image',vars={'param':'1'})}}" /> <img alt="2" src="{{=URL(r=request,f='get_image',vars={'param':'2'})}}" /> <img alt="3" src="{{=URL(r=request,f='get_image',vars={'param':'3'})}}" /> and sometimes just the first image appears, sometimes the 1st and the 2nd, sometimes the 1st and the 3rd, and very rare all... If i insist on pressing F5 to reload the images very fast, web2py loses the session, and creates another file in the session folder. "get_image" is a very used controller, and after digging in some foruns and in the web2py documentation, i've read something like web2py has the session object locked, and maybe it is what has been happening here: the first call to "get_image" locks the session, and then the second can't access the session (maybe the browser parallels the calls to the controler), and instead of waiting for the unlock, web2py fails miserably. To go around this, i've added to function "get_image" a session.forget(), so now it is something like this: def get_image(): ---session.forget() ---(....) In the web2py book it is written this about session.forget(): "It tells web2py not to save the session. This should be used in those controllers whose actions are called often and do not need to track user activity.". If this kind of behavior is the purpose for "forgetting" the session, maybe this should be better documented in that section of the book (4.8 - session). To me, that sentence about sentence.forget sounds something like "When web2py finds this, it will discard and throw away your session data.." Maybe this things of locking/unlocking of session objects should be better documented because it reflects web2py details which are unknown for the users. Or maybe i'm wrong in my conclusions, but the fact is that now all three images (see code above) appear and the problem seems to be solved. But i'm not very secure about this... Well, web2py still is a great framework, and i'll definitely keep using it! :) Congratulations for web2py, Massimo. Thanks, João Ventura On 6 Jun, 17:47, João Ventura <joaojonesvent...@gmail.com> wrote: > Hello again Massimo, and thanks for the feedback. > > I've been troubleshooting this all day long and i've tracked this down > to a view that i have that serves 2 images and two tables with > information from those two images. > That view is something like (the syntax is not this, just for > illustration purposes): > > <div> > <div id="1"> > <img src=URL(.....,f="generate_image",param=1) /> > {{python code for the table using information on the > session...}} > </div> > <div id="2"> > <img src=URL(.....,f="generate_image",param=2) /> > {{python code for the second table using information on the > session...}} > </div> > </div> > > All the tables are ok, but only the first image appears. If i go call > the URL of the second image directly on the browser url textarea, or > using firebug, the second image appears ok. The only difference > between both images is a parameter that calls inside the default.py > the function generate_image, but one parameter generates one kind of > image, the other parameter other kind of image. The images use > information from the session. > > So what i found so far is: > - both images called separately work fine > - one after the other gives problems with session things > - both images are called one after the other, but it seems that at the > second time, the session object isn't defined at the time of function > call, and if i do a kind of "if (session.something is not None)" and > give something like a alert image, web2py creates a new session file > and leaves the first session file in the "session" folder.. > > It seems, that the second time the method "generate_image" is called, > the session is still not ready. If i don't return nothing, web2py > works fine. If i do a 'if' inside "generate_image" to return an alert, > web2py creates a new session and leaves the other in the folder. > > Is there any way of "enforcing" the session object to be ready when a > function in default.py is called? Even if that slows down the response > from the server.. > > I'll keep on exploring, thanks, > João Ventura