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-21 Thread Zbigniew Lukasiak
On Fri, Oct 16, 2009 at 5:24 PM, iain wrote: > 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 ); >

Re: [Catalyst] Validating single arg id

2009-10-16 Thread Bill Moseley
On Fri, Oct 16, 2009 at 7:31 AM, J. Shirley 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"';

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 wit

Re: [Catalyst] Validating single arg id

2009-10-16 Thread J. Shirley
On Fri, Oct 16, 2009 at 7:19 AM, Matt Whipple 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: > > sub some_acti

Re: [Catalyst] Validating single arg id

2009-10-16 Thread J. Shirley
On Fri, Oct 16, 2009 at 6:45 AM, 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 v

Re: [Catalyst] Validating single arg id

2009-10-16 Thread Matt Whipple
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 wit

[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 cou