[Catalyst] [Fwd: $c->forward design question]

Michael Henson mhenson at silverthorneinc.com
Mon Feb 26 05:24:14 GMT 2007


Hi,

I'm using $c->forward() to call "service" handlers which do various
business-logic actions. One such service is a selector that finds a
product in our catalog - if we have enough information to determine
which one we want. Valid return values can be the db id of the row, the
object for the product, or undef if nothing is found.

The problem is that 'undef' doesn't come back from the $c->forward call.
The specific line that causes the trouble in my case is
Catalyst.pm:1167 :

    eval { $c->state( &$code( $class, $c, @{ $c->req->args } ) || 0 ) };

Catalyst::execute seems to set $c->state to 0 as a default initializer.
Is there is a deeper reason it does this? Would it break anything if
there was an extra step to add a check for an actual undef return value
(vs. no return value), allowing the undef to come through?

Incidentally, that line looks like it would also transform anything that
evaluates as false to a 0 as well (empty list, empty string, string of
all spaces, etc.).

PS.: I'm aware that I could just use non-controller modules for the same
overall purpose, but I'm also trying to take advantage of Catalyst's
debugging and profiling abilities on my dispatched methods.

Michael Henson
mhenson at silverthorneinc.com





More information about the Catalyst mailing list