[Catalyst] setup() called twice

Matt S Trout dbix-class at trout.me.uk
Tue Jun 19 18:46:51 GMT 2007


On Tue, Jun 19, 2007 at 06:19:30PM +0100, Matt Lawrence wrote:
> Matt S Trout wrote:
> >On Tue, Jun 19, 2007 at 04:52:08PM +0100, Matt Lawrence wrote:
> >  
> >>Matt S Trout wrote:
> >>    
> >>>On Tue, Jun 19, 2007 at 09:50:30AM +0100, Matt Lawrence wrote:
> >>>      
> >>>>What's wrong with:
> >>>>
> >>>>$_->setup for keys %{$self->_plugins};
> >>>>    
> >>>>        
> >>>Setup order matters.
> >>>
> >>>  
> >>>      
> >>Fine, the order is known in setup(), but gets discarded.
> >>
> >>$class->setup_plugins($flags->{plugins});
> >>
> >>...
> >>
> >># Call plugins' setup
> >>$_->setup for @{delete $flags->{plugins} || []};
> >>    
> >
> >Still completely broken.
> >
> >Read half a dozen plugins' setup methods and come back when you have a 
> >clue.
> >
> >  
> 
> Nothing like a bit of random abuse to spark off a bit of development work...

Shame it didn't spark off you actually going and reading what I suggested you
did before you wasted your time and the list's.

Tell you what, I'll read the setup methods for you and spell it out:

Some plugins initialize themselves before the next plugin is setup by doing

sub setup {
  my $app = shift;

  <setup code here>

  $app->NEXT::setup(@_);
}

(example: Catalyst::Plugin::Authentication)

Some do so after by doing

sub setup {
  my $app = shift;

  $app->NEXT::setup(@_);

  <setup code here>
}

(example: Catalyst::Plugin::Session)

Some do both (example: Catalyst::Plugin::Cache).

Now do you understand why your approach isn't going to work?

-- 
      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