38 messages in com.googlegroups.pylons-discussRe: An idea for improving @validate| From | Sent On | Attachments |
|---|---|---|
| Steven Holmes | 28 Jan 2008 17:33 | |
| Mike Orr | 28 Jan 2008 22:33 | |
| Alberto Valverde | 29 Jan 2008 00:35 | |
| Steven Holmes | 29 Jan 2008 01:44 | |
| Qiangning Hong | 29 Jan 2008 03:01 | |
| Dmitry Lipovoi | 29 Jan 2008 03:05 | |
| Steven Holmes | 29 Jan 2008 03:27 | |
| Mike Orr | 29 Jan 2008 08:21 | |
| Steven Holmes | 29 Jan 2008 08:43 | |
| Matt Feifarek | 29 Jan 2008 08:52 | |
| Steven Holmes | 29 Jan 2008 09:05 | |
| Ian Bicking | 29 Jan 2008 09:40 | |
| Mike Orr | 29 Jan 2008 10:50 | |
| Ian Bicking | 29 Jan 2008 11:14 | |
| Mike Orr | 29 Jan 2008 11:25 | |
| Matt Feifarek | 29 Jan 2008 11:35 | |
| Ian Bicking | 29 Jan 2008 11:45 | |
| Mike Orr | 29 Jan 2008 12:32 | |
| Ian Bicking | 29 Jan 2008 12:46 | |
| Ben Bangert | 29 Jan 2008 12:56 | |
| Ben Bangert | 29 Jan 2008 12:57 | |
| Ben Bangert | 29 Jan 2008 13:05 | |
| Ian Bicking | 29 Jan 2008 13:05 | |
| Philip Jenvey | 29 Jan 2008 13:10 | |
| Philip Jenvey | 29 Jan 2008 13:10 | |
| Matt Feifarek | 29 Jan 2008 13:11 | |
| Ben Bangert | 29 Jan 2008 13:19 | |
| Ian Bicking | 29 Jan 2008 13:26 | |
| Ben Bangert | 29 Jan 2008 13:38 | |
| Mike Orr | 29 Jan 2008 14:51 | |
| Steven Holmes | 29 Jan 2008 14:54 | |
| Mike Orr | 29 Jan 2008 15:00 | |
| Mike Orr | 29 Jan 2008 15:17 | |
| Ian Bicking | 29 Jan 2008 15:27 | |
| Ben Bangert | 29 Jan 2008 15:59 | |
| Ian Bicking | 29 Jan 2008 16:05 | |
| Mike Orr | 29 Jan 2008 16:09 | |
| Steven Holmes | 29 Jan 2008 17:07 |
| Subject: | Re: An idea for improving @validate![]() |
|---|---|
| From: | Ian Bicking (ianb...@public.gmane.org) |
| Date: | 01/29/2008 11:14:44 AM |
| List: | com.googlegroups.pylons-discuss |
Mike Orr wrote:
On Jan 29, 2008 9:40 AM, Ian Bicking
<ianb...@public.gmane.org> wrote:
Matt Feifarek wrote:
Yes, we're disagreeing on what the default should be. Well, you'll have to convince Ben. I think he likes it the other way.
I don't have this particular religion, but what would a REST zealot say? Seems like two different URI's for the same thing is bad.
REST zealots say that you should have:
GET /resource -> rendered thing GET /resource/edit -> form POST /resource -> make the change
So there is generally another URL involved. But REST zealots don't deal with HTML forms.
This gets into how Pylons should support REST, and what this implies for the changes I'm making in Routes 2. Ben and I discussed map.resource a week ago, and he said it follows the Atom Publishing Protocol, a widely-respected REST spec. I haven't studied it yet but here are some links on it.
http://tools.ietf.org/html/rfc5023 http://www.ibm.com/developerworks/library/x-atompp1/
As a recap, map.resource believes that:
GET /messages => display index page POST /messages => create new message GET /messages/new => display add form (action = POST /messages) GET /messages/1 => display message 1 GET /messages/1/edit => display edit form (action = PUT /messages/1) PUT /messages/1 => modify message 1 DELETE /messages/ 1 => delete message 1
(Routes 1 has ";edit" instead of "/edit", but Ben said that's an invalid URL syntax borrowed from Rails, which Rails has since corrected.)
PUT and DELETE are implemented by an "_action" query param to a POST form, which Routes notices and changes the request method. Again, Ben says this is widely done in other programming languages.
It's kind of wonky, though, because web applications don't expose "resources". When you get /messages you get an HTML page. You don't get a well-formed container of resources like in atompub. When you get /messages/1 you get HTML again. When you edit you send application/x-form-www-urlencoded (or whatever it is). That's not the same content type as what you were given (HTML). It's not even that close to the same content type. (Though the intention of a FormEncode Schema is actually to take a resource and turn it into something isomorphic to an HTML form, and then convert it back again... but expressing form submissions as a transformation of data is tricky.)
As long as you are doing this, you might want to consider some kind of validation submission as well, that can be used by Javascript to submit and get errors. Also a preview submission.
I think using POST is okay; if you are using _action=PUT it isn't a PUT anyway, and it feels like it's not much more than HTTP verb push-ups. POST over a resource updates the resource in some fashion; updating a resource in-place via POST is okay (PUT might be better, but not-really-a-PUT *isn't* better).
Ian




