[Catalyst] setup() called twice
    Quinn Weaver 
    quinn at fairpath.com
       
    Mon Jun 18 19:50:06 GMT 2007
    
    
  
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.
This seems like a bad idea--I imagine there are CPAN modules that can't
handle being initialized twice.  Fortunately, there's a work-around:
just initialize those modules in MyApp.pm, but outside of setup.
But why would you want to initialize all your Catalyst plugins twice?
Is this just some quirk that's being preserved for historical reasons?
Just curious,
-- 
Quinn Weaver, independent contractor  |  President, San Francisco Perl Mongers
http://fairpath.com/quinn/resume/     |  http://sf.pm.org/
510-520-5217
    
    
More information about the Catalyst
mailing list