[Catalyst] Controller methods
Matt S Trout
dbix-class at trout.me.uk
Tue Jan 17 14:02:59 CET 2006
On Tue, Jan 17, 2006 at 08:53:25AM +0000, Will Hawes wrote:
> Matt S Trout wrote:
> >On Mon, Jan 16, 2006 at 09:36:31PM +0000, Will Hawes wrote:
> >>I tracked down an error in my code today that was caused by accidentally
> >>returning an objectref (a DBIx::Class::ResultSet, but the type is
> >>probably unimportant) from one of my controller methods. The offending
> >>code was something along the lines of
> >>
> >>sub myaction : Local {
> >> ...
> >> $self->fetch_objects( $c );
> >> # return 1; # <- this fixed it..
> >>}
> >>
> >>where fetch_objects() is the action I use to run all my CDBI/DBIC
> >>searches.
> >>
> >>First, what are valid things to return for a controller action? IMO it
> >>would be very useful if Catalyst could warn()/die() if it gets something
> >>unexpected. This type of error would become much easier to debug.
> >
> >Arbitrary things should normally be acceptable return values so that they
> >can be returned by ->forward.
>
> Does this mean completely arbitrary things, or just Catalyst components
> (which could be checked for)? Sorry if that's a dumb question but I'm
> trying to think of other types of object that are used with forward().
Not used with, returned from. There's a difference :)
sub foo :Private {
my ($self, $c) = @_;
...
return $some_random_thing;
}
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Catalyst
mailing list