+
+ my $frontend = 'Apache::MVC' if $ENV{MOD_PERL};
+
+ my $masonx;
+ if ( grep { /^MasonX$/ } @plugins )
+ {
+ $masonx++;
+ @plugins = grep { ! /^MasonX$/ } @plugins;
+ $frontend = 'MasonX::Maypole';
+ }
+
+ $frontend ||= 'CGI::Maypole';
+
+ $frontend->require or die "Loading $frontend frontend failed: $@";
+ push @ISA, $frontend;
+
+ my $autosetup=0;
+ my @plugin_modules;
+ {
+ foreach (@plugins) {
+ if (/^\-Setup$/) { $autosetup++; }
+ elsif (/^\-Debug(\d*)$/) {
+ my $d = $1 || 1;
+ no strict 'refs';
+ *{"$caller\::debug"} = sub { $d };
+ warn "Debugging (level $d) enabled for $caller";
+ }
+ elsif (/^-.*$/) { warn "Unknown flag: $_" }
+ else {
+ my $plugin = "Maypole::Plugin::$_";
+ if ($plugin->require) {
+ push @plugin_modules, "Maypole::Plugin::$_";
+ unshift @ISA, "Maypole::Plugin::$_";
+ warn "Loaded plugin: $plugin for $caller"
+ if $caller->can('debug') && $caller->debug;
+ } else {
+ die qq(Loading plugin "$plugin" for $caller failed: )
+ . $UNIVERSAL::require::ERROR;
+ }
+ }
+ }
+ }