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 On 6 Jun, 14:57, mdipierro <mdipie...@cs.depaul.edu> wrote: > On Jun 6, 4:45 am, João Ventura <joaojonesvent...@gmail.com> wrote: > > > Hello mdipierro, > > > i only store basic python datatypes (dictionaries, floats, strings). > > The most complex variables that i store are dictionaries inside other > > dictionaries, with a max depth of 2 (i.e., a first dictionary with > > secondary dictionaries inside it). > > It is a bit strange for, while using the same client browser on the > > same app instance (i.e., without reloading), after a while web2py > > ignores the first session file and creates a second one. In other > > words, in what situations is web2py designed to do this behavior? > > No. web2py reuses the same sessions for the same client over and over, > unless it fails to retrieve a session. > Try print request.cookies. It may help figure it out. > > > Also, are there any kind of methods for clearing the session files? > > You can have the app itself clear them or you can use a cron script > like admin/cron/expire_sessions.py > > > Because with this kind of behavior, one gets the session folder filled > > up very fast.. Is there any possibilty of session timeout and file > > deletion? > > move admin/cron/expire_sessions.py into your app cron > > > Ah, this has already happened before, and the only common thing that > > i've detected so far is that i use tab navigation with jquery's ajax > > function to load content to a div. Any hints? > > I do not understand. Sorry. > > > Thanks, > > João Ventura > > > PS: I'll try to debug my application down to the web2py source code to > > see if something triggers my thought. Any ideia where to start > > searching? > > By the way, web2py is a great framework, i've started with Django, > > couldn't do almost no production there, switch to web2py, and > > production increased a lot... Just this annoying session behavior, but > > hope it's a small bug.. > > > On 6 Jun, 06:36, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > The only thing that comes to mind is if you try store an object in the > > > session. The object may be an instance of class that you define and > > > therefore web2py succeeds in storing the session but fails to retrieve > > > it because the class is not yet defined (or imported) at the time when > > > the session is retrieved (before your user code it executed). > > > > You can only store primitive types in session, not objects. > > > > On Jun 5, 9:04 pm, João Ventura <joaojonesvent...@gmail.com> wrote: > > > > > Hello everyone, > > > > > i've searched a lot but couldn't find any answer to the following: I'm > > > > developing a web application, and i rely heavily on sessions, storing > > > > all the user data on a session while the user uses a jquery tab > > > > interface. The problem is that sometimes web2py loses the session > > > > object, and it is almost in the same manner. I've checked my code many > > > > times and i don't mess with the session object. > > > > > But as web2py does manage sessions automatically, i see that the first > > > > time i use the app, web2py creates a session file in the session > > > > folder. And when the contents of the first session disappears, when i > > > > check the "sessions" folder, the previous session file is there with > > > > all its contents, but now there's a new (empty) session file. > > > > > I can't give a simple example how to replicate the error, but i think > > > > web2py shouldn't lose the first session, because: > > > > - I haven't explicitely called anything like "session.forget()" that > > > > could influence. > > > > - I haven't opened any other browser instance, tab or any other > > > > browser at all. > > > > > Anybody knows anything about this? > > > > > Thanks, > > > > João Ventura