Hi,

In my application I would like AJAX invoked GETs and POSTs to edit the 
state of the application by editing attributes in the session.  I'm having 
trouble though when the requests overlap, meaning not all changes to the 
state are saved.

Below is a minimal example to reproduce the problem. First visit /, then 
/status to see that only one of the session attributes is updated, not 
both. /status shows for me "state1 = 1 state2 = 0"

Thanks in advance for any help,

Matt

import web, time

urls = (
    '/', 'index',
    '/1', 'one',
    '/2', 'two',
    '/status', 'status',
)
web.config.debug = False

app = web.application(urls, globals())
session = web.session.Session(app, web.session.DiskStore('sessions'))



class one(object):
    def GET(self):
        session.state1 = 1
        time.sleep(1)
        return "done"
    
class two(object):
    def GET(self):
        session.state2 = 1
        return "done"
    

class index(object):
    def GET(self):
        session["state1"] = 0
        session["state2"] = 0
        return """
                <iframe src="/1"></iframe><iframe src="/2"></iframe><a 
href="/status">status</a>
            """
        
class status(object):
    def GET(self):
        out = ""
        if "state1" in session.keys() :
            out += "state1 = " + str(session["state1"])
        else :
            out += "state1 not set"
        if "state2" in session.keys() :
            out += " state2 = " + str(session["state2"])
        else :
            out += "state2 not set"
        return out
        
    


if __name__ == '__main__':    
    app.run()

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to