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

_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to