[mod_python] Session managment for mod_python

Damjan arhiv at freemail.org.mk
Sun Oct 15 15:10:06 EST 2000


> what do you mean by session management?
> 
The best session managment would be a Python dictionary, that is global
to all subinterpreters, and all Apache processes, and that retains its
state across handlers and requests.

Let me illustrate what can be done with this. For example you have
people log-in to your site and you first create a "User" object, set
some attributes to it (ex. preferences). Then you create a semi-random
string, you send that string as a cookie to the users browser, and use
the string as a key in the session managment dictionary. Later when that
user accesses another page on your site, the only thing you do is:

		from mod_python.session_managment import SM
		cookie = getcookie("something")
		user = SM[cookie]
		buf = "Hello " + user.real_name
		if user.show_folders
			# do stuff
		if user.something
			# do other stuff
		...
		etc.

Of course you could do this with a database and pickle-ing the user
object. Or you could do this with a shared memory.

Do you think there should be a standard mod_python module that does all
of this?  

-- 
damjan





More information about the Mod_python mailing list