Geert Jansen
geert at boskant.nl
Tue Sep 4 16:48:44 EST 2001
Good day, First of all: mod_python is great! I've been using it a couple of months now to develop an (yet another, yes I know:) ASP like environment for Apache, and I really like it. But now I stumbled on a problem. I'm having difficulty implementing a global "Application_OnStart" event. The event should be executed by my ASP environment before the first request is served, but, only _once_ for the whole server, _not_ one time per child. This event is very handy for initializing application wide (database backed) variables so I'd really like to provide it... I could not find a way to satisfactorily implement this with the current mod_python. To solve the problem I wrote a small patch to servermodule.c that adds two member variables: "my_generation" and "restart_time". "my_generation" is the current generation of the child (the number of restarts), and "restart_time" is the time of the last (re)start. Using these variables I am able to implement the "Application_Onstart" event: I keep the last restart time in an application global variable. At child startup, I look at this value. If it is not equal to the current restart time, I raise "Application_OnStart" and update the restart time (with the necessary locking of course). The patch is attached. Could this be applied? I think this could suit other developers too. Thanks for your time! Greetings, Geert Jansen -- long long email=0X78DC806B91FCA334,i=0,j; main(){j=(email>>4*i)&15; putchar(j+j/2+j/5-j/12+(j<13?97:-65+7*j));i/15?exit(0):++i,main();} -------------- next part -------------- A non-text attachment was scrubbed... Name: mod_python-restart.diff Type: application/octet-stream Size: 1041 bytes Desc: not available Url : http://mailman.modpython.org/pipermail/mod_python/attachments/20010904/49e62fbc/mod_python-restart-0003.obj
|