That would mean that sleep() has to be coded "defensively" so that it stillI remember that this was basically the result of our discussions, yes. At the time, I thought it was better to be defensive and notice the occasional exception than to have unpredictable things happen because cleanup doesn't get run.
works properly even if awake() failed halfway through (which is a change to
current semantics):
def sleep(self, trans):It's pretty easy just to set them to None. No tests required then. That's what we do.
if hasattr(self, '_bar'): del self._bar
if hasattr(self, '_foo'): del self._foo
Base.sleep(self, trans)
We often do a bunch of state-related cleanup in sleep...I used to not like requiring sleep() to be written in this way but I think I'm changing my mind -- this may be the best way to go. I'd like to hear other opinions though.
I usually don't even bother writing a sleep() because there's no harm in leaving around the values I've stored in self until the next request.
Sure, we could just clean up in the next round of awake... make sure that sane defaults are there before we do anything.
What about something like a database connection (oh, say, maybe a ZODB connection ;-)? You'd need to close/release it sometime.
------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
