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.
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?)
But most of the time actions expect to be writing in the place of def
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
Also note that postaction writes '</html>'
But to answer your question the approproate way to handle a security
type login would be in
which should always run before any HTML output to the browser.
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
> def actions(self):
> return Page.actions(self) + ["submit"]
> def submit(self):
> trans = self.transaction()
> if password = "xxxxx":
>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"
><body color=black bgcolor=white>
>Do I need to call some sort of flush() function before redirecting the response?
"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