hi guys,

I'm trying to learn some of the catalyst internals and now I'm stuck at some particular code, just cant figure out how it works.

The code can be found here:
http://dev.catalyst.perl.org/browser/trunk/Catalyst-Runtime/lib/ Catalyst.pm#L825

It's the one calling all plugins' setup subs.

I wrote a sample script which should simulate the whole process involed in loading and calling plugins setup.

package plugin_a;

use NEXT;
sub setup {
	my $self = shift;
	print "begin plugin_a ($self)\n";
	$self->NEXT::setup;
	print "after plugin_a ($self)\n";
}

package plugin_b;

use NEXT;
sub setup {
	my $self = shift;
	print "begin plugin_b ($self)\n";
	$self->NEXT::setup;
	print "after plugin_b ($self)\n";
}

package plugin_c;

use NEXT;
sub setup {
	my $self = shift;
	print "begin plugin_c ($self)\n";
	$self->NEXT::setup;
	print "after plugin_c ($self)\n";
}

package runtime;

use NEXT;
sub setup {
	my $self = shift;
	my $class = ref($self) || $self;
	print "begin runtime ($self)\n";
	if ($test::variant == 1) {
		$class->NEXT::setup;
	} elsif ($test::variant == 2) {
		local *setup = sub { };
		$class->setup;
	}
	print "after runtime ($self)\n";
}
sub register {
	my $self = shift;
	my $class = ref($self) || $self;
	my $plugin = shift;
	unshift @{"$class\::ISA"}, $plugin;
}
sub list_isa {
	my $class = shift;
	print "isa: $_\n" for @{"$class\::ISA"};
}

package app;

use base qw/runtime/;

app->register("plugin_a");
app->register("plugin_b");
app->register("plugin_c");

package test;

our $variant = shift(@ARGV) or die "$0 1|2";

app->list_isa;
app->setup;

As you can see, I've gotten two variants, the NEXT variant works as expected (lucky guess), the other one just got me totally lost. I thought it would be right the same as NEXT, and then redo all plugins until runtime comes again (evil thought), but instead it stopped at the first ISA entry.

Anyone can explain me that behaviour and then the behaviour of catalyst?
Any help would be appreciated!

bye Alex


_______________________________________________
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