[Catalyst] OT: edit/add seperate actions?

Zbigniew Lukasiak zzbbyy at gmail.com
Wed Mar 4 07:12:53 GMT 2009


On Tue, Mar 3, 2009 at 11:35 PM, Peter Karman <peter at peknet.com> wrote:
> Zbigniew Lukasiak wrote on 03/03/2009 04:18 PM:
> - Show quoted text -
>> On Tue, Mar 3, 2009 at 10:27 PM, Peter Karman <peter at peknet.com> wrote:
>>> Zbigniew Lukasiak wrote on 03/03/2009 02:53 PM:
>>>
>>>>> If you use CatalystX::CRUD::REST, you can do:
>>>>>
>>>>>    # POST      /foo                -> create new record
>>>>>    # GET       /foo                -> list all records
>>>>>    # PUT       /foo/<pk>           -> update record
>>>>>    # DELETE    /foo/<pk>           -> delete record
>>>>>    # GET       /foo/<pk>           -> view record
>>>>>    # GET       /foo/<pk>/edit_form -> edit record form
>>>>>    # GET       /foo/create_form    -> create record form
>>>>>
>>>>> CatalystX::CRUD::REST uses the C::R::REST::ForBrowsers feature of
>>>>> 'x-tunneled-method' param to support PUT and DELETE via POST.
>>>> And where do the forms submit?  I mean what is their action address?
>>>> Do they submit to themselves - or does edit_form submit to
>>>> /foo/<pk>?x-tunneled-method=PUT and create to /foo both with POST
>>>> method?  And it is the second - then what do you do when the form
>>>> parameters are incorrect and you need to redisplay the form?
>>> using the CXC REST API:
>>>
>>> if you GET /foo/1234, then you must PUT /foo/1234 to save it.
>>> (or POST /foo/1234?x-tunneled-method=PUT  -- although I always put the
>>> x-tunneled-method value in a hidden input body param, not as part of the
>>> URL).
>> Sure - that was just for clarification of how the PUT is done with browsers :)
>>
>>
>>> if you GET /foo/create_form, then you must POST /foo.
>>>
>>> When the form is redisplayed on validation error, it just retains the
>>> original action.
>>
>> I was just thinking about the possible CRUD REST schemas and it found
>> that under that schema you display the same form under two addresses:
>> /foo/1234/edit_form and /foo/1234 (in case of the error).  And the
>> other day I had that idea that perhaps instead of using path part -
>> use another parameter so /foo/1234?x-view-method=edit_form  would
>> render the form and /foo/1234 would render the standard view of the
>> object.   This way the form would have just one address.
>>
>
> In CXC REST, /foo/1234 is analogous to /foo/1234/view in the RPC format.
> It does not return a HTML form. It just returns the object data. I.e.,
> read-only. So the URLs represent two different things.

But they do represent two views on the same object - one is as you say
'read-only' the other is the form filled with it's values.  The same
object - two different renderings.  That is what I meant.


-- 
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/



More information about the Catalyst mailing list