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...
This patch implements what I was driving at. All tests pass with
Catalyst::Runtime 5.7007.
I didn't include a test for the case of overridden setup, but it should
be fixed. Feel free to flame me if it's not.
Matt
--- Catalyst-Runtime-5.7007/lib/Catalyst.pm 2007-02-28 15:20:30.000000000
+0000
+++ Catalyst-Runtime-5.7007-plugin-patch/lib/Catalyst.pm 2007-06-19
18:08:12.000000000 +0100
@@ -807,8 +807,11 @@
$class->setup_home( delete $flags->{home} );
+ # We will need this later on..
+ my $plugins = delete $flags->{plugins};
+
$class->setup_log( delete $flags->{log} );
- $class->setup_plugins( delete $flags->{plugins} );
+ $class->setup_plugins( $plugins );
$class->setup_dispatcher( delete $flags->{dispatcher} );
$class->setup_engine( delete $flags->{engine} );
@@ -860,10 +863,11 @@
}
# Call plugins setup
- {
- no warnings qw/redefine/;
- local *setup = sub { };
- $class->setup;
+ for my $plugin (@{ $plugins || [] }) {
+ if (defined(my $setup = $plugin->can('setup'))) {
+ $setup->($class);
+ last;
+ }
}
# Initialize our data structure
_______________________________________________
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/