When webkit.page runs an action it first runs
preaction, then your action then postaction

The default preaction as defined in Page.py is:
def preAction(self, actionName):
       """
       Invoked by self prior to invoking a action method. The
       implementation basically writes everything up to but not
       including the body tag.  Subclasses may override to customize
       and may or may not invoke super as they see fit. The actionName
       is passed to this method, although it seems a generally bad
       idea to rely on this. However, it's still provided just in case
       you need that hook.
       """
       self.writeDocType()
       self.writeln('<html>')
       self.writeHead()

I personally don't like this, since I often redirect like you do, you can make a SitePage that inherits from webkit.page and base your servlets on that.

In the SitePage you should override preaction to do nothing (unless there is a common preaction - in which case stick it there, maybe a security level check?)

def preaction(self,actionName):
   pass

But most of the time actions expect to be writing in the place of def content.
So in webkit page you can have an action return "ACTION SUCCEEDED!!" and that will be placed in the body of a reasonable HTML page.


Since we just broke that by overriding preaction your action will now be responsible for creating an entire HTML page. (Or you cna have it just call self.writeHTML)

Also note that postaction writes '</html>'

But to answer your question the approproate way to handle a security type login would be in
def awake()
which should always run before any HTML output to the browser.


-Aaron



Eric Radman wrote:

What is the appropriate way to redirect a web browser to another page? This is
what I'm doing now:

from WebKit.Page import Page

class login(Page):
 def actions(self):
   return Page.actions(self) + ["submit"]

 def submit(self):
   trans = self.transaction()
   if password = "xxxxx":
     trans.response().sendRedirect("welcome")

This does call the next servlet called 'welcome', but before it does the
following is written to the response object:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>
<html>
<head>
  <title>welcome</title>
</head>
<body color=black bgcolor=white>

Do I need to call some sort of flush() function before redirecting the response?





--
-Aaron
http://www.MetroNY.com/
"I don't know what's wrong with my television set. I was getting
C-Span and the Home Shopping Network on the same station.
I actually bought a congressman."
   - Bruce Baum




------------------------------------------------------- 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