[mod_python] Persistent variables?

Grant Beasley gbeasley at tsa.ac.za
Tue Jan 29 12:47:06 EST 2002


Hi

Firstly, I hope this hasn't already come up, but I've searched the archives
back a few months and can't find anything.

I have a mod python authentification script which, upon authentification,
reads user details from a database and places them in a global dictionary
indexed on the userid. This is kept in a separate module (called Globals),
and accessed through functions in the global module. This dictionary seems
to persist through HTTP connections, so on subsequent calls I can just read
the dictionary instead of the database.

I haven't come up with any problems thus far, except that isinstance doesn't
seem to function correctly. If I create a Widget instance and store it in my
global dictionary, on subsequent sessions, although the Widget instance
exists, and widget.__class__ is equal to the Widget class (in string terms),
isinstance returns 0. I'd assume this is because I've somehow reloaded the
Widget class and hence it does not compare equally to the class stored with
the original widget instance.

I hope that makes sense and doesn't sound like complete gibberish. Can
anyone explain this to me, and indicate whether storing user data like this
is safe and sensible? Should I be reading user details from my database?

Thanks
Grant Beasley
Technikon SA




More information about the Mod_python mailing list