In your __init__.py, you can add a contextInitialize() function. After the
__init__.py is imported, the contextInitialize() (if any) will get called
with 2 arguments: the Application object, and the path to the context
directory. So you can put this into __init__.py:
def contextInitialize(app, ctxPath):
app.addShutDownHandler( ... )
This is not very well documented, but if you google for "contextInitialize"
you will actually find my PowerPoint presentation from the last Python
conference which mentions this obscure feature :-)
> -----Original Message-----
> From: Stefan Schwarzer [mailto:stefan.schwarzer@...]
> Sent: Tuesday, October 01, 2002 10:41 AM
> To: webware-discuss@...
> Subject: [Webware-discuss] Adding shutdown handler during context
> In my context's __init__.py I want to initialize some things for the
> application server to run (e. g. filling caches whose filling takes a
> rather long time).
> I also want to register a shutdown handler that (currently only) will
> write something to a custom log file when the application server is
> shut down. From within a servlet, I would grab the application object
> and call its addShutDownHandler method, however, I see no such
> possibility from within the mentioned initialization of the context.
> A workaround would be to register the shutdown handler on calling the
> first servlet for the first time, though that doesn't seem like a
> clean solution to me. :-)
> Any suggestions?
> This sf.net email is sponsored by: DEDICATED SERVERS only $89!
> Linux or FreeBSD, FREE setup, FAST network. Get your own server
> today at http://www.ServePath.com/indexfm.htm
> Webware-discuss mailing list
Get latest updates about Open Source Projects, Conferences and News.