38 messages in com.googlegroups.pylons-discussRe: An idea for improving @validate
FromSent OnAttachments
Steven Holmes28 Jan 2008 17:33 
Mike Orr28 Jan 2008 22:33 
Alberto Valverde29 Jan 2008 00:35 
Steven Holmes29 Jan 2008 01:44 
Qiangning Hong29 Jan 2008 03:01 
Dmitry Lipovoi29 Jan 2008 03:05 
Steven Holmes29 Jan 2008 03:27 
Mike Orr29 Jan 2008 08:21 
Steven Holmes29 Jan 2008 08:43 
Matt Feifarek29 Jan 2008 08:52 
Steven Holmes29 Jan 2008 09:05 
Ian Bicking29 Jan 2008 09:40 
Mike Orr29 Jan 2008 10:50 
Ian Bicking29 Jan 2008 11:14 
Mike Orr29 Jan 2008 11:25 
Matt Feifarek29 Jan 2008 11:35 
Ian Bicking29 Jan 2008 11:45 
Mike Orr29 Jan 2008 12:32 
Ian Bicking29 Jan 2008 12:46 
Ben Bangert29 Jan 2008 12:56 
Ben Bangert29 Jan 2008 12:57 
Ben Bangert29 Jan 2008 13:05 
Ian Bicking29 Jan 2008 13:05 
Philip Jenvey29 Jan 2008 13:10 
Philip Jenvey29 Jan 2008 13:10 
Matt Feifarek29 Jan 2008 13:11 
Ben Bangert29 Jan 2008 13:19 
Ian Bicking29 Jan 2008 13:26 
Ben Bangert29 Jan 2008 13:38 
Mike Orr29 Jan 2008 14:51 
Steven Holmes29 Jan 2008 14:54 
Mike Orr29 Jan 2008 15:00 
Mike Orr29 Jan 2008 15:17 
Ian Bicking29 Jan 2008 15:27 
Ben Bangert29 Jan 2008 15:59 
Ian Bicking29 Jan 2008 16:05 
Mike Orr29 Jan 2008 16:09 
Steven Holmes29 Jan 2008 17:07 
Subject:Re: An idea for improving @validate
From:Steven Holmes (steg@public.gmane.org)
Date:01/29/2008 02:54:37 PM
List:com.googlegroups.pylons-discuss

On 29 Jan 2008, at 18:51, Mike Orr wrote:

@validate is another issue. It's a nice convenience but it does limit what you can do in your code. Going to a one-method scheme would require it to be bypassed or rewritten in the application. I've also found another problem in that the forms I'm porting to Pylons have a Cancel button, which is supposed to bypass the validators and do a redirect. I'd either have to have a big OR validator around all the others, or wrap or rewrite @validate to process "cancel" before executing the validators.

So, I think the Pylons docs need to mention @rewrite's limitions and show how to work around them (calling the validators manually in the action), and perhaps also show the one-method technique. However, I'm not sure the one-method technique will be supported by map.resource, though you can use arguments to get something approaching that.

I'm not sure what you mean by one-method scheme.

What I was suggesting for @validate would still have two methods on the controller, one for form processing and one for displaying the form. It's just these would be accessed at the *same* URL, being differentiated by whether it was POST or a GET.

This is exactly what happens now when re-submitting a form that didn't validate... the form is redisplayed at, say, /account/create and also POSTed to /account/create. The difference is that there is an extra / account/create_form URL through which the form is accessed initially. What good does this extra URL do? As far as I can tell, none. So what I'm proposing isn't fundamentally different from what happens already with @validate, and it's not using any techniques that are not already used in the current @validate.

Regarding URLs, I only have the very vaguest idea of what REST is. Much like Matt, I structure my URLs like this:

/account/create <-- Create an account (GET displays the form, POST creates the account and redirects to /account/id) /account/id <-- Displays the account details /account/id/edit <-- Edit account details (similar to /account/create) /account/delete <-- Deletes the account (GET gives a form asking confirmation, POST does the deletion).

This has worked very well for me so far.

Cheers,

Steven