I've come up with what I think will work for my needs, with regard to
breaking up the application's sub-sections. 

A group of section modules might look like this:

./My/App.pm              (ISA CGI::Application)
./My/index.cgi           (see below for contents)
./My/App/Sales.pm        (ISA My::App)
./My/App/Inventory.pm    (ISA My::App)
etc...

App.pm provides common functions, like new() or other app-specific code,
while each sub-module has the section-specific code, including all the
needed run-modes.

Now, my index.cgi would look like this:

#!/usr/bin/perl
use CGI qw(:standard);
my $q = new CGI;
my $modules = {
       sales => 'Sales',
       invent => 'Inventory',
   },
};
# Set a default
$q->param('mod' => 'main')
   unless $q->param('mod');
# Dynamically pull in the right section's module
require "ComponentManager/$modules->{$q->param('mod')}{load}.pm";
# And fire it off
my $app = "ComponentManager::$modules->{$q->param('mod')}{load}"->new($q);
$app->run();
__END__

So far, the above seems like it will be a good solution.

On another note, I would however like to pass html to run() at the
base-class level, and have it place it in the output appropriately.
There is currently no way to do that gracefully, because the http
headers are built into the run method.

One thought that comes to mind is to have run() accept two scalars, the
values being strings that it prepends and appends, respectively, to the
runmode's output. Don't know how great an idea that is.

Another possibility might be to, within the run() sub, simply store the
return value of cgiapp_prerun(), to be output just before the run-mode's
return value. That would solve the header problem, and for any common
footers we could just use teardown().

Any thoughts?

-Sebastian


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.vm.com/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to