Re: [Catalyst] Validating single arg id

2009-10-21 Thread iain
Zbigniew Lukasiak wrote: What is the advantage of this over: sub view : Local { my ( $self, $c, $id ) = @_; $self-start( $c, $id ); # do something with $c-stash-{obj} return 1; } For me there are lots of little reasons. I suppose its a personal choice. I like the URI structure

Re: [Catalyst] Validating single arg id

2009-10-17 Thread Bill Moseley
On Fri, Oct 16, 2009 at 7:31 AM, J. Shirley jshir...@gmail.com wrote: What database do you use? In MySQL and SQLite I get no exception at all: Postgresql. $ perl -Ilib -e 'use MyApp; my $obj = MyApp-model('Schema::User')-find(bogus); print defined? . ( defined $obj ? yes : no ) . \n';

[Catalyst] Validating single arg id

2009-10-16 Thread Bill Moseley
I have a number of methods that start something like this: sub view : Local Args(1) { my ( $self, $c, $id ) = @_; my $obj = $c-model( 'DB::Foo' )-find( $id ) || return $c-res-status( 404 ); If $id is not valid then I might, as in that example, return with a 404 status. Of

Re: [Catalyst] Validating single arg id

2009-10-16 Thread J. Shirley
On Fri, Oct 16, 2009 at 7:19 AM, Matt Whipple m...@mattwhipple.com wrote: I would probably avoid potentially hitting the database unnecessarily, and only use the exception in the case of complicated validation. In the case of simple validation, why not something simple along the lines of:

Re: [Catalyst] Validating single arg id

2009-10-16 Thread iain
Bill Moseley wrote: I have a number of methods that start something like this: sub view : Local Args(1) { my ( $self, $c, $id ) = @_; my $obj = $c-model( 'DB::Foo' )-find( $id ) || return $c-res-status( 404 ); If $id is not valid then I might, as in that example, return with a