X-Git-Url: https://git.decadent.org.uk/gitweb/?p=maypole.git;a=blobdiff_plain;f=lib%2FMaypole%2FApplication.pm;h=a0e49bc5fbacf33164441c4ed5c08e769dbe8ec9;hp=f05379d87c8ab8035118aac9ff6fb8dc44b86d62;hb=7f1d3cd72f5b45850f7faa380704bbb633c58f77;hpb=a556ccee86cac8093fa4f62fb340d94e6c10517d diff --git a/lib/Maypole/Application.pm b/lib/Maypole/Application.pm index f05379d..a0e49bc 100644 --- a/lib/Maypole/Application.pm +++ b/lib/Maypole/Application.pm @@ -30,10 +30,12 @@ sub import { push @ISA, $frontend unless __PACKAGE__->isa( $frontend ); my $autosetup=0; + my $autoinit=0; my @plugin_modules; { foreach (@plugins) { if (/^\-Setup$/) { $autosetup++; } + elsif (/^\-Init$/) { $autoinit++ } elsif (/^\-Debug(\d*)$/) { my $d = $1 || 1; no strict 'refs'; @@ -59,6 +61,7 @@ sub import { $caller->config(Maypole::Config->new); $caller->config->masonx({}) if $masonx; $caller->setup() if $autosetup; + $caller->init() if $autosetup && $autoinit; } 1; @@ -88,7 +91,7 @@ So Maypole::Plugin::Config::YAML becomes Config::YAML. use Maypole::Application qw(Config::YAML); -You can also set special flags like -Setup and -Debug. +You can also set special flags like -Setup, -Debug and -Init. use Maypole::Application qw(-Debug Config::YAML -Setup); @@ -108,6 +111,25 @@ Note that no options are passed to C. You must ensure that the required model config parameters are set in Cconfig>. See L for more information. +=head2 -Init + + use Maypole::Application qw(-Setup -Init); + +is equivalent to + + use Maypole::Application; + MyApp->setup; + MyApp->init; + +Note that the C<-Setup> flag is required for the C<-Init> flag to work. + +In persistent environments (e.g. C), it is useful to call C +once in the parent server, rather than at the beginning of the first request +to each child server, in order to share the view code loaded during C. +Note that you must supply all the config data to your app before calling +C and C, probably by using one of the C +plugins. + =head2 -Debug use Maypole::Application qw(-Debug);