Matt Feifarek wrote:
> Geoffrey Talvola wrote:
>
>> Aha. Exceptions can definitely cause sleep() to be skipped.
>>
>> If an exception happens during respond() or during awake() then
>> sleep() does not get called. This smells like a bug to me.
>>
>>
> I always thought that this was funny. We wrap up the
> EndResponse(s) that
> we raise with a .cleanup() method (which is usually called
> from sleep).
>
> SO, we're still cleaning up, even when EndResponse is sent.
> But this is
> basically working around what we think is a design flaw in the whole
> endresponse idea.
>
>
>> Looking at this more closely, there ought to be a try/finally in
>> there so that sleep() always gets called if awake() succeeds,
>> something like:
>>
>>
> I've thought the same thing, and have been meaning to whine
> about it to
> the list. If awake runs, sleep should run. And you may be
> right; maybe
> it should ALWAYS run.
That would mean that sleep() has to be coded "defensively" so that it still
works properly even if awake() failed halfway through (which is a change to
current semantics):
def awake(self, trans):
Base.awake(self, trans)
self._foo = Foo()
self._bar = Bar()
def sleep(self, trans):
if hasattr(self, '_bar'): del self._bar
if hasattr(self, '_foo'): del self._foo
Base.sleep(self, trans)
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.
- Geoff
-------------------------------------------------------
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