-if ( $ENV{MOD_PERL} ) {
- require Apache::MVC;
- push @ISA , qw(Apache::MVC);
-}
-else {
- require CGI::Maypole;
- push @ISA , qw(CGI::Maypole);
+ 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;
+ }
+ }
+ }
+ }
+ no strict 'refs';
+ push @{"${caller}::ISA"}, @plugin_modules, $class;
+ $caller->config(Maypole::Config->new);
+ $caller->config->masonx({}) if $masonx;
+ $caller->setup() if $autosetup;