[mod_python] Session handling in mod_python 2.7

Erdi Balint erdibalint at freemail.hu
Wed Oct 19 02:21:46 EDT 2005


Hi,

I would like to use sessions in mod_python 2.7 and as I saw on the 
mod_python faq, version 2.7 does not include this, so I installed Myghty 
to achieve this. My question is how do access the Myghty session from 
mod_python's Request object? So if I have in trivia.py:

from mod_python import apache
from myghty.session import Session

...

def login(req):
     req.session = Session(req,data_dir='/tmp')
     req.session['faz'] = user_row['id']
     req.session.save()
     req.headers_out['location'] ='http://localhost/trivia/trivia.py/main'

...

def main(req):
     session = req.session ## this yields an AttributeError, what should 
be put here?	

I reckon that I have to replace the mod_python Request object (req) with 
the Request object from the Myghty package, but I am not sure how or if 
there is another (maybe simpler solution). In the Myghty documentation 
it says that there is interaction between mod_python and Myghty but it 
is not very detailed on what I'm asking :(

Thank you for your help,
Balint


More information about the Mod_python mailing list