[albatross-users] Handling user data error in forms

Gregory Bond gnb at itga.com.au
Wed Dec 18 12:59:17 EST 2002


What are people doing to handle bad user data entered into forms?

I've been doing things like:

    def page_process(self, ctx):
	if ctx.req_equals('submit'):
	    try:
		d = check_date(ctx.locals.date)
	    except DateError, e:
		ctx.locals.errmsg = "Unparsable date " + str(e)
		ctx.set_page('error')
		return

but this simple scheme doesn't seem to work very well with the navigation (I'm
using server-based sessions).  It's not to bad for browser-based sessions, or
simple apps with a single form on the front page, but breaks down if there are
multiple forms in server-sessions.  (In particular, the browser "back" button
doesn't necessarily go where the user might think it ought.)

Are there any better ways of handling this?  Perhaps by letting exceptions 
percolate somewhere up the albatross stack?





More information about the Albatross-users mailing list