Kasturirangan Rangaswamy
Wed, 01 Dec 2004 21:12:32 -0800
Hi, I am building a web-based system and am trying to use CGI::Application and HTML::Template to achieve both a modular structure and design/code separation.
My design goal can be summarized as:
-- Base.pl is instance script for base module Base.pm
-- Base.pm throws a HTML page with a link which links to
another instance script data_entry_index.pl
-- data_entry_index.pl is instance script for data_entry.pm
module which I want to be the child of Base.pm and be
able to have access to it's app instance but is not!
Base.pm module
-----------------------------------------------------------
#!/usr/local/bin/perl
package BASE;
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use DBI;
use HTML::Template;
use CGI::Session qw/-ip-match/;
use base 'CGI::Application';
sub setup {
my $self = shift;
$self->start_mode('display_entry_screen');
$self->run_modes(
'display_entry_screen' => 'display_entry_screen',
);
}
sub display_entry_screen {
my $self = shift;
# I am purposely setting this parameter to test if it
# is accessible in the child module
$self->param('here' => 'here');
my $data_entry_screen =
"/software/cgi-bin/SoftwareDistribution/data_entry/
data_entry_index.pl";
my $index_page = $self->load_tmpl('index_screen.tmpl',
die_on_bad_params => 0,
cache => 1
);
$index_page->param(data_entry_link =>
$data_entry_screen);
$index_page->output;
}
-----------------------------------------------------------
and am calling the above module using the following instance script
Base.pl
------------------------------------------------------------
#!/usr/local/bin/perl
use lib '/export/home/r/rangask/software/cgi-bin/SoftwareDistribution';
use base 'BASE';
use strict;
my $webapp = BASE->new(TMPL_PATH
=> '/export/home/r/rangask/software/html/'
);
$webapp->run();
------------------------------------------------------------
Now Base.pm results in a screen with a single link from where I call
another instance script. That instance script calls a module which
needs to use Base.pm
as it's 'parent'. But I find thats not happening. The code is pasted
below
data_entry_index.pl
------------------------------------------------------------
#!/usr/local/bin/perl
use lib
'/export/home/r/rangask/software/cgi-bin/SoftwareDistribution/data_entry';
use data_entry;
use strict;
use lib '/export/home/r/rangask/software/cgi-bin/SoftwareDistribution';
use base 'BASE';
my $webapp = data_entry->new(
TMPL_PATH => '/export/home/r/rangask/software/html/'
);
$webapp->run();
------------------------------------------------------------
data_entry.pm
------------------------------------------------------------
#!/usr/local/bin/perl
package data_entry;
use CGI::Application;
use CGI::Session;
use CGI::Application::ValidateRM;
use Data::FormValidator;
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use HTML::Template;
use lib '/export/home/r/rangask/software/cgi-bin/SoftwareDistribution';
use base 'BASE';
sub setup {
my $self = shift;
$self->start_mode('data_entry_user_details');
$self->run_modes(
'data_entry_user_details'
=> 'data_entry_user_details',
);
}
sub data_entry_user_details {
my $self = shift;
# This should have given me a 1 because of the 'here' param I set in
Base.pm but it gives
a '0'!!
return $self->param();
}
------------------------------------------------------------
Please advise: Is my code wrong or is this design flawed for what I am
trying to accomplish?
Thanks,
Sharad
__________________________________
Do you Yahoo!?
Meet the all-new My Yahoo! - Try it today!
http://my.yahoo.com
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]