[mod_python] Persisten DB connection for passwords.

Stefan C. Kremer skremer at q.cis.uoguelph.ca
Mon Oct 13 19:56:43 EST 2003


I have built a web-site that uses a persistent DB connection as suggested 
in the FAQ to store user passwords for my web-site.

The existence of the separate connections (for each python process) is
problematic in this case, because one hit on the web-page will initialize
the password (or change it) with an SQL update and then another hit to the
same page (but on a different PID) may or may not get the lastest version
of the password with SELECT.

I understand that this is a product of the multiversion model concurrency
control (MVCC) which is generally desirable and specifically desirable for 
my web-site except for the password UPDATE and SELECT commands and the 
persistent connections I'm using with mod_python.

I've been poring over the documentaion and am still a little bit unsure of 
what the easiest way to approach this is (serializable isolation lever, 
table-level locks, row-level locks, SELECT FOR UPDATE) and where to apply 
it (during the UPDATE statement, SELECT statement, or both).  The 
problem is complicated by the fact that I can't easily test it because I 
never know when the transactions will be autocommitted and which PID my 
http get will get.  I'm looking for a nice simple solution that will work 
with this rare case (i.e. please don't suggest switching to a 
different DB, using mod_perl instead ;), etc.).

I'm hoping that someone else has tried something similar and can offer a 
suggestion or pointer (or even a snippit of SQL).

FYI the DB is Postgres-7.3 (built from source), mod_python is 3.0 (built 
from source), DBA is PoPy 2.0.11 (built from source) all living on top of 
an otherwise stock RH 9.0.

Thanks in advance,


Permanently                             Temporarily (Until Aug. 2004)
Dr. Stefan C. Kremer, Associate Prof.   Visiting Researcher
Reynolds Building, 106                  307 Computer Science/Engineering Bldg
Dept. of Computing & Info. Science      School of Info. & Computer Science
University of Guelph, Guelph, Ontario	  U of California at Irvine, Irvine, CA
N1G 2W1                                 92697-3425
Tel: (519)824-4120 Ext.58913  
Fax: (519)837-0323

WWW: http://q.cis.uoguelph.ca/~skremer  E-mail:  skremer at uoguelph.ca

More information about the Mod_python mailing list