[mod_python] Problems with Apache locking up when passing session variables in mod_python

Mark Jordan mjordan at nngov.com
Wed May 12 16:53:52 EDT 2004


We are building a web based application using Apache 2.0.48, mod_python 
3.1.2b, Python 2.3.2. and are having problems setting/passing session 
variables in mod_python .  It seems like a common enough task, to pass 
login info from one screen to another by means of a session variable.  
But we can't seem to get it working.  I have scoured the list and don't 
see a complete sample of code for setting, passing and outputting/using 
session variables for something like this.

We have a form on a page called "login.htm"  which passes the form input 
(a user name and password) to a psp page ("contents.psp") with the 
statement:

  <FORM NAME="electForm" METHOD="POST" ACTION="psp/contents2.psp">

This is just one simple text box and a password type input box (at this 
point there is not even any validation or security going on)

The psp page "contents.psp" begins with:

<%
#ESTABLISH SESSION VARIABLES
#-----------------------------------------------------------------
req.session = Session.Session(req)
req.session['userid'] = form.getfirst("login")
req.session['userPass'] = form.getfirst("password")
req.session['dbUser'] = "username"
req.session['dbPass'] = "passwordtxt"
req.session.save()
#req.session.unlock()
#-----------------------------------------------------------------
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>

Then after the head, body, div stuff at the top of the html in the psp 
page, we are outputting the two passed variable as a check

<%
req.write(req.session['userid'])
req.write(req.session['userPass'])
%>

Althought this works the first two or three times, even after completly 
stopping the Apache server and restarting it, after the first two or 
three times the Apache server locks up.  It keeps polling and never 
returns.  Even closing the browser and restarting the browser or 
entirely different brower doesn't help. 
Only a complete restart of the Apache server will correct it and then we 
are back where we started.

Any assistance would be greatly appreciated!   We are trying to get some 
sample government applications off the ground to prove to the existing 
programming staff that the Opensource community is a viable alternative 
to M$ commercial products.  So all sticking points are viewed as another 
black mark against Python/Apache etc. 

Thanks
Mark


More information about the Mod_python mailing list