You can put startup code in awake() and cleanup code in sleep() methods of a servlet.  These methods get called at the beginning and end of every request for that servlet.  For example:
 
 
class MyPage(Page):
    def awake(self, trans):
        Page.awake(self, trans)
        # your code goes here
 
    def sleep(self, trans):
        # Your cleanup code goes here
        Page.sleep(self, trans)
 
The servlets never get deleted until the app server is shut down -- they get reused instead.  That's why you have to put your cleanup code in sleep() instead of __del__().
 
- Geoff
-----Original Message-----
From: Meh Lounge [mailto:mehlng@yahoo.com]
Sent: Friday, October 22, 2004 9:46 AM
To: Geoffrey Talvola; Webware-discuss@lists.sourceforge.net
Subject: RE: [Webware-discuss] __del__ equivalent webware function

But how can I add this thing per servlet?
I'm having a servlet (or context) that opens a DB connection when started and need to close it when it is done. Can't I add a close() function to the context/servlet? this should be changed IMHO.

Geoffrey Talvola <gtalvola@nameconnector.com> wrote:
Meh Lounge wrote:
> Can anyone please provide me with such function. How
> can I order webware to do thing when a servlet or when
> a context is closed?

You can call Application.addShutDownHandler(func) where func is any callable
object. It will be called when the app server is shut down.

- Geoff


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Webware-discuss mailing list
Webware-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-discuss


Do you Yahoo!?
vote.yahoo.com - Register online to vote today!