From 7f1d3cd72f5b45850f7faa380704bbb633c58f77 Mon Sep 17 00:00:00 2001 From: David Baird Date: Sat, 20 Aug 2005 13:00:19 +0000 Subject: [PATCH] implement -Init flag in Mp::Application - rt #14123 git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@375 48953598-375a-da11-a14b-00016c27c3ee --- Changes | 1 + lib/Maypole/Application.pm | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index aad9d28..9872249 100644 --- a/Changes +++ b/Changes @@ -10,6 +10,7 @@ For information about current developments and future releases, see: Simplified Net::Amazon example (bug 14073) Apache2 fix in Apache::MVC (bug 13888) Maypole::Session::generate_unique_id() now returns the id (bug 14124) + Implement -Init flag in Mp::Application (wishlist 14123) 2.10 Tue 19 Jul 2005 Multiple Template Paths added ( http://rt.cpan.org/NoAuth/Bug.html?id=13447 ) 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); -- 2.39.2