Ian Bicking wrote:
> Aaron Held wrote:
> > I like actions the way they are - they are very simple to understand.
> > If you have a hello "Aaron" type app its easy to setup a servlet like
> >
> > def writeContent(self):
> > self.write('<form><input type="text" name="username"><submit
> > name="_acctionHello"</form>');
> >
> > def hello(self):
> > self.write('Hello %s' % self.request().value('username','No
> User Name'))
>
> Where it gets all annoying, though, is preAction and postAction, which
> are like an anemic form of the writeHTML, writeHead, writeTitle,
> writeStyleSheet etc. setup that Page has for normal requests. Or, where
> you don't want to write anything, but way to treat the action as an
> action (i.e., something that does something, not something that merely
> changes the display) -- there again preAction and postAction get
> in the way.
>
> Ian
We change the meaning of preAction and postAction in our site's base Page
subclass. Works very well:
def preAction(self, action):
pass
def postAction(self, action):
# By default, all actions are followed by drawing the page
# Servlets with actions that draw screens can override
self.writeHTML()
def writeHTML(self):
if not self.response().hasHeader('Location'):
self.writeDocType()
self.write('\n<html ...snip...>\n\n')
self.writeHead()
self.writeBody()
self.write('\n</html>')
NOTE: the if statement to check for Location is unnecessary if you always
follow sendRedirect with endResponse, or use sendRedirectAndEnd. This
implementation pre-dates the existence of that exception handling framework,
and was left in for backwards compatability.
Although we've never had to override preAction in another subclass, I could
envision some framework doing it. I think the structure of actions works
well in the 0.8.1 implementation. I'll second Aaron's vote for "simple to
understand".
Regards,
Ben
-------------------------------------------------------
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