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 <[EMAIL PROTECTED]> 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@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@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/