[Catalyst] setup() called twice

Matt S Trout dbix-class at trout.me.uk
Mon Jun 18 20:04:09 GMT 2007


On Mon, Jun 18, 2007 at 11:50:06AM -0700, Quinn Weaver wrote:
> Hi, all,
> 
> During some debugging, I noticed that MyApp::setup is called twice.
> This looks like an intentional feature.  My question is, why?
> 
> From MyApp.pm:
> 
>    my $ret = $self->SUPER::setup( @_ );
> 
> From Catalyst.pm:  
> 
>     # Call plugins setup
>     {
>         no warnings qw/redefine/;
>         local *setup = sub { };
>         $class->setup;
>     }
> 
> Yep, the latter code locally redefines the parent class setup to a
> no-op in order to prevent an infinite loop, then calls the child class
> (MyApp) setup.  The effect is that every line in MyApp::setup is
> executed twice.

No it isn't. The redefine means it -isn't- called a second time.

But all the plugins' setup() methods (which weren't in @ISA when setup was
first called) -are- called.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/             http://www.shadowcatsystems.co.uk/ 



More information about the Catalyst mailing list