Matt Feifarek wrote:
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).

Actions are always -- that's what defaultAction is there for.


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

from Servlet.py (CVS):


    def runTransaction(self, trans):
        try:
            self.awake(trans)
            self.respond(trans)
        finally:
            self.sleep(trans)

You can change this fairly easily since it's a method of Servlet now, and not Application. EndResponse and other exceptions from HTTPExceptions are still handled by Application (though you are free to trap them in your servlet as well, again using runTransaction -- Component.CPage does this).

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.

You need some way of dealing with this -- if sleep has to be cautious about how it is called, then so be it; *something* has to be cautious. There's always a possiblity of exceptions -- if you don't call sleep, then you have to be cautious that you haven't left resources open when other errors occur.


To me exceptions seem like exactly the right mechanism for redirects, not flags. Flags work, but they are limited -- I think we should avoid them, at least for something as common as a redirect.

A lot of good things come out of exceptions that can't come from flags. You can raise permission exceptions deep in libraries that don't have access to the servlet. You can raise a 404 in your servlet based on extraURLPath, and it looks just like it would if the servlet itself hadn't been found, and so on.

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.

Well, we don't actually agree, because I wasn't actually saying we *should* encourage the use of a flag, only that we could. Right now I've been working on user management components (svn://w4py.org/LoginKit), and a more formalized way to control output seems necessary to me. Perhaps that can just be isolated in CPage (a componentized version of Page), or maybe there's another way to manage these, but we need something.


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.



------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to