Hi there, I'm working on a simple progress-bar type feature whereby
some progress information (eg,  {'percentage': 25}) is stored in the
request.session and then read out again by an ajax callback from the
browser.
The code looks a bit like this:

@view_config(route_name="my_page", renderer="my_page.html")
def my_page(request):
    """ main page request """
    request.session.progress = {'percentage': 0};
    return {}

@view_config(route_name="progress", renderer="json")
def get_progress(request):
   """ get progress data """
    return request.session['progress']

@view_config(route_name="progress", renderer="json")
def get_slow_results(request)
   """ long-running request to retrieve some results """
   res = []
   for i, job in enumerate(things_to_do):
        res.append(job())
        request.session['progress'] = {'percentage' :  float(i) /
float(len(things_to_do)) * 100.0}
        request.session.changed()
   return res

So the browser hits my_page, and then registers 2 ajax callbacks, one
to get_progress() and one to get_slow_results().
Each call to get_progress()  triggers another one 1 second later until
its finished.

Now the problem is, that until get_slow_results() has finished and
returned its Response, the browser's calls to get_progress() return
the original session.progress, which is {'percentage': 0}.
When get_slow_results() has finished, it jumps up to {'percentage':
100'}.

Am I missing something fundamental here?
I'm using Pyramid 1.3, with pyramid_beaker sessions in in-memory
mode.

Thanks in advance,
Edward

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to