From: Matt F. <ma...@da...> - 2004-04-22 16:43:38
|
Ian Bicking wrote: > We have defaultAction now. It's only wonky because it doesn't call > preAction/postAction, where all other actions do. But if we get rid > of those, then it's not a problem. Anyway, defaultAction now just > calls writeHTML. I don't think output is an action. Output is always; actions are sometimes. Having a servlet with no output doesn't make sense (even if the output isn't html, but is an HTTP code... see below). > I'm still not clear what the problems are with sendRedirectAndEnd()? > If there's a bug there we should fix it -- otherwise we're fine right > now. From Application.py: (from 0.8.1) try: self.awake(transaction) try: self.respond(transaction) except EndResponse: pass self.sleep(transaction) except EndResponse: pass Therefore, calling the method from awake does not call sleep. This is bad. And people have pointed out that sleep may crash if it tries to close something that hasn't been opened in awake; which would happen if you raise the exception before that "something" was opened. This is also bad. It's best not to mess with awake and sleep just to send a redirect. Only mess with output. But my larger point is basically that a redirect IS output. It's an HTTP condition. It should come from response, as it does. To make this special "hijack" metaphor is wrong, especially if we end up coding the above so that it doesn't in fact hijack. The proper metaphor is to simply not do writeHTML, and send the alternate output of a redirect. It's still a response; the normal servlet "thing" is still happening. The response is not "ended" at all. If we want to keep a close method name, I would support just changing it to "sendRedirect", which would set a flag and change the output from response accordingly. > Right now there's no analog for non-HTML output. You just override > writeHTML and write other text. It's a misnomer, but it works fine. > However, for some actions you may wish to suppress writeHTML. Of > course you can code this yourself (setting some flag), but it might be > nice to include. Forcing writeHTML to be called by the action would > serve to do this. I agree; if you want to stop output from actions (and not use the redirect pattern that I've been talking about) it should be up to you to change that behavior. I do not think that we should make it so every action needs to call writeHTML at the end. > > The only thing special about awake is that it happens before respond. > So I don't think it matters. > Agreed. |