Michael C. Neel
neel at mediapulse.com
Thu Mar 11 10:27:57 EST 2004
Actually, everything is correct here, server.register_cleanup is intended to take a request object. There are two cleanups you can use in Apache (I don't know if mod_pytohn does them both, going off of Apache API here). One is the request cleanup, the other server cleanup. Request cleanup is run as the very last phase of the request, after the logging phase and after the client connection is closed. Anything that you need to custom delete from a request can be done here, but sometimes you want to keep something arounf for another request - an example is the log file it self, you don't want to open and close this file each request, but rather open it the first request and keep it open for all requests following. This is where server cleanup comes it. It is registered from a request, but doesn't execute until the server is shutdown. This means the parent apache process is killed, not the children. So in code you would see if the log file was open, if not open it and register a server cleanup to close it. If it was open, just get the file handle. The advantage of this method over serverinit/servershutdown and childinit/childshutdown (not currently supported in mod_python, but in the Apache API) is that setup can be done at request time, per directoy and/or query args, for very unique requirments. It's very dated now, but the Orilley book "Apache Modules in C and Perl" is probably the best thing out there for understanding the Apache API. It's not hard to read that and then take it to mod_python. Maybe the next edition will be "Apache Modules in C, Perl and Python"? =) Mike > -----Original Message----- > From: Ben [mailto:ben at medianstrip.net] > Subject: Re: [mod_python] server cleanup > > > ah, interesting. something for a the FAQ i guess. hope you don't > mind me quoting you there. > > B > > On Thu, 11 Mar 2004, Gregory Bond wrote: > > > (IIUC from last time this was asked...) > > > > because apache lazy-evaluates the config info and only > builds server objects > > when a request for that (possibly virtual) server arrives. > > > >
|