[Catalyst] Detach won't detach?

Lars Balker Rasmussen lars at balker.dk
Mon Jan 26 19:05:50 GMT 2009


On Mon, Jan 26, 2009 at 07:56:53PM +0100, koniczynek wrote:
> sub auto :Private {
>   my ( $self, $c ) = @_;
> 
>   $c->log->debug('action start');
>   if ( ! user_logged_in) {
>     $c->redirect( $c->req->base );
>   } else {
>     $c->detach( $c->action->{name} );
>   } 
>   $c->log->debug('action end');
> }

auto relies on a return value to tell the dispatcher whether to continue or not.
Doing the normal action is the default, detaching to it is redundant, hence:

sub auto :Private {
  my ( $self, $c ) = @_;

  if ( ! user_logged_in) {
    $c->redirect( $c->req->base );
    return 0;
  }

  return 1;
}

This example is pretty much exactly the same as in the main Catalyst pod.
-- 
Lars Balker Rasmussen                                        Consult::Perl



More information about the Catalyst mailing list