1AutoRunmode::FileDelegaUtsee(r3)Contributed Perl DocumenAtuattoiRounnmode::FileDelegate(3)
2
3
4
6 CGI::Application::Plugin::AutoRunmode::FileDelegate - delegate CGI::App
7 run modes to a directory of files
8
10 # in file runmodes/my_run_mode.pl
11 sub {
12 my ($app, $delegate) = @_;
13 # do something here
14 };
15
16 # in file runmodes/another_run_mode
17 sub {
18 # do something else
19 };
20
21
22 package MyApp;
23 use base 'CGI::Application';
24 use CGI::Application::Plugin::AutoRunmode
25 qw [ cgiapp_prerun];
26 use CGI::Application::Plugin::AutoRunmode::FileDelegate();
27
28 sub setup{
29 my ($self) = @_;
30 my $delegate = new CGI::Application::Plugin::AutoRunmode::FileDelegate
31 ('/path/to/runmodes')
32 $self->param('::Plugin::AutoRunmode::delegate' => $delegate);
33 }
34
35 # you now have two run modes
36 # "my_run_mode" and "another_run_mode"
37
39 Using this module, you can place the definition of your run modes for a
40 CGI::Application into directory of files (as opposed to into a Perl
41 module).
42
43 Each run mode is contained in its own file, named foo.pl for a run mode
44 called foo. The run modes are lazily evaluated (on demand) for each
45 request. In the case of mod_perl this means you can update them
46 without restarting your web server. In the case of plain CGI it means a
47 reduced startup cost if you have many run modes (because only the one
48 that you need gets parsed and loaded, along with dependent modules).
49
51 With all the namespace nesting going on the name of this module has
52 reached an intolerable Java-esque length.
53
55 If you like the idea of moving everything outside of Perl modules into
56 seperate files, you should also have a look at
57 CGI::Application::Plugin::TemplateRunner, which does a similar thing
58 for HTML templates and the Perl code needed to provide them with data.
59
61 Thilo Planz, <thilo@cpan.org>
62
64 Copyright 2005 by Thilo Planz
65
66 This library is free software; you can redistribute it and/or modify it
67 under the same terms as Perl itself.
68
69
70
71perl v5.12.0 2009-02-14 AutoRunmode::FileDelegate(3)