Graham Dumpleton
graham.dumpleton at gmail.com
Wed Jan 20 23:42:21 EST 2010
2010/1/21 Raphaël B. <nashii at gmail.com>: > Hello, > > I'm attempting to create some web application with mod_python, but as soon > as I call one attribute/method that is linked to the session module, the > navigator is "freezing" (not exactly, in fact, it is searching the webpage, > and searching, and searching ...) > > I'm working with mod_python.psp in apache, but I have tried with > mod_python.publisher too, and neither is working ... > > psp: there is just that in the page: > > <% > if not hasattr(req,'session'): > req.session = Session.Session(req) The session object is already created for you by PSP so these lines should not be needed. > if req.session.is_new(): > req.write("Hello !") > %> You should though from memory only be accessing session object as 'session' and not 'req.session'. This is because PSP will look for the fact that 'session' is used and use that as a basis of creating it for you. It is possible that the way you are doing this is deadlocking the request on itself as you can't have one request create two session objects. Once it is deadlocked like that, even if you close the browser it says deadlocked and so further requests will also be locked out. Thus, fix the code, restart Apache to get rid of deadlock and start over. > and publisher: > > #!/usr/bin/python You don't need the above line. > # -*- coding: iso-8859-1 -*- > > import sys > from mod_python import apache, util, Session > > def index(req): > req.content_type = "text/plain; charset=iso-8859-1" > req.send_http_header() > req.write("Hello world!\n") > sess = Session.Session(req) As a guideline, always save session as 'req.session'. Further, if needing to create/access sessions in sub functions, always a good idea to use the pattern: def function(req): if not hasattr(req, 'session'): req.session = Session.Session(req) If you don't do this, you risk deadlocking on yourself again. Graham > return "Bye bye!" > > Both are freezing. > > I think my head will explode if it continue >< > > Could you please help me ? Perhaps apache is misconfigured for mod_python ? > Could you give me some way to correct the problem ? > > Thank you very much, > Raphaël > > PS: Excuse me for my english, i'm French. > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python > >
|