[Catalyst] Dispatching with Chained vs HTTP method

Moritz Onken onken at houseofdesign.de
Wed Apr 30 10:46:09 BST 2008


Hi Zbyszek,

do you plan FormFu support? In case the submitted values are not valid  
the response is a xml/json/whatever which includes the error messages.
That would be really great :)

cheers,

moritz


Am 30.04.2008 um 11:24 schrieb Zbigniew Lukasiak:

> Hi Toby,
>
> I don't know if you are aware - but building a REST-like CRUD
> interface to DBIx::Schema is my long term goal (started with
> Catalyst::Example::InstantCRUD).  Do you think we could collaborate?
>
> Cheers,
> Zbyszek
>
> On Wed, Apr 30, 2008 at 10:26 AM, Toby Corkindale  
> <tjc at wintrmute.net> wrote:
>> just looking for some advice on the best way to do something..
>>
>> So I wrote a controller class using Chained that basically auto- 
>> converts any
>> DBIx::Schema (which includes a tiny extra base class itself) into a  
>> REST API..
>> Well, a simple one anyway - it supports find and search so far, and  
>> foreign
>> keys in the objects get serialised into hashes of the URIs to fetch  
>> them.
>>
>> All working nicely so far, but this is all for GET queries.
>>
>> But the behaviour should be different depending upon whether you
>>    GET /item/1234
>> or
>>    DELETE /item/1234
>> etc.
>>
>> I was thinking something like this: (Abbreviated code below)
>>
>> ------------
>> sub item_by_id : Chained CaptureArgs(2) {
>>    my ($self, $c, $type, $id) = @_;
>>    $c->stash->{item} = $c->model("DB:$type")->find($id);
>> }
>>
>> sub delete : Chained('item_by_id') Args ActionClass('MethodDELETE') {
>>    my ($self, $c) = @_;
>>    $c->stash->{item}->delete;
>> }
>>
>> sub modify : Chained('item_by_id') Args ActionClass('MethodPUT') {
>>    my ($self, $c) = @_;
>>    $c->stash->{item}->update($c->request->params);
>> }
>> ------------
>> Then the appropriate ActionClasses would check if the $c->req- 
>> >method eq 'GET'
>> or 'DELETE' or whatever.
>>
>> But I was just wondering if you had other ideas, and if using  
>> ActionClasses
>> with Chained actions is crackfuelled and going to lead to a world  
>> of misery and
>> pain.
>>
>> Cheers!
>> Toby
>>
>> _______________________________________________
>> List: Catalyst at lists.scsys.co.uk
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
>> Dev site: http://dev.catalyst.perl.org/
>>
>
>
>
> -- 
> Zbigniew Lukasiak
> http://brudnopis.blogspot.com/
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/




More information about the Catalyst mailing list