[SPAM] [mod_python] [SPAM] modpython session under linux apache 2.2 mpm-worker

Jim Gallacher jpg at jgassociates.ca
Fri Sep 1 08:13:10 EDT 2006


It's not immediately obvious from your code why it might hang, but I can 
tell you the session part will not work as written. When a session is 
created a corresponding cookie is set in the response header. However 
your have a req.write() call before you create your session object. The 
first req.write() will cause the headers to be sent to the client, so 
the session cookie will never be sent. Sesssion.Session() must happen 
before any req.write() call.

Jim

guo tie wrote:
> hi,
>   all.
>   i found the mod_python session under linux apache 2.2 mpm-worker have
> problem.
> 
> linux: 2.6.17
> apache: 2.2 mpm-worker
> python: 2.4.3
> mod_python 3.2.10
> 
> Now, the test.py is :
> 
> from mod_python import apache
> from mod_python import Session
> import sys
> 
> class Dispatcher(object):
>    def __init__(self, req):
>        self._req = req
>        self._uri =  req.uri
> 
>    def dispatch(self, req):
>        req.content_type =      'text/plain'
>        import mod_python
>        req.write(mod_python.version)
>        req.write('\n')
>        self.sess =     Session.Session(req)
>        req.write("after create session\n")
>        self.sess['obj'] =      'abcdtest'
>        req.write("after sess['ob'] = 'abcdtest'\n")
>        self.sess.set_timeout(60 * 60)
>        req.write("after self.set_timeout(60 * 60)\n")
>        self.sess.save()
>        req.write("after sess.save()\n")
>        req.write(self.sess['obj'])
> 
>        return apache.OK
> 
> def handler(req):
>    mypatch =   Dispatcher(req)
>    return mypatch.dispatch(req)
> 
> when i use ie or firefox visit the page, i was hanged after output
> 3.2.10
> 
> i think this is the session bug with apache mpm mode, i see somebody else
> have mentioned it .
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list