Thanks for your prompt response. I mean to use sessions but posted that earlier code in a fit of ignorance. I made some changes to my code to implement sessions and still am having the same issue. I will paste my modified code below.
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 cgiapp_init { my $self = shift; my $cgi = $self->query(); #Create a new session my $session = new CGI::Session(undef, $cgi->cookie('CGISESSID') || $cgi->param('CGISESSID') || undef, {Directory=>' /export/home/r/rangask/software/cgi-bin/tmp'}) || die 'Session could not be created'; } 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 $session->param('here', 'here'); $self->param('session', $session); 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'; use strict; my $webapp = BASE->new(TMPL_PATH => '/export/home/r/rangask/software/html/' ); $webapp->run(); ------------------------------------------------------------ Now I come to the next instance script called from a link in a HTML page thrown by BASE.pm 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'; my $webapp = data_entry->new( TMPL_PATH => '/export/home/r/rangask/software/html/' ); $webapp->run(); ------------------------------------------------------------ which calls the modulke below (inherits from BASE.pm) 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; my $cgi = $self->query(); my $sid = $cgi->cookie('CGISESSID') || $cgi->param('CGISESSID') || undef; return "sid" . $sid; my $session = new CGI::Session(undef, $sid, {Directory=>' /export/home/r/rangask/software/cgi-bin/tmp'}) || die 'Session could not be created'; # I was hoping to get the session value here but do not. return $session->param("here"); my $data_entry_user_details_page = $self->load_tmpl('data_entry_user_details.tmpl', die_on_bad_params => 0, cache => 1 ); $data_entry_user_details_page->output; } --------------------------------------------------------------------------------------- What I am hoping for but am not getting is: In BASE.pm ----------- Find a session using either cookies or query string (N/A as I am not passing one) or set one up. Use 'file::Driver' using new CGI::Session(); In data_entry.pm ----------------- Use new CGI::Session again. My understanding is it will look for CGISESSID in either cookies or query string and if found will attach itself to that session (which is a file in my case correctly stored in the /tmp directory). Problem is, it is not getting that 'here' variable still. In data_entry.pm, I am checking for $sid and am drawing a blank there too. Cookies are enabled on my browser. Could anyone who is an expert on sessions help me? Thanks, Sharad --- Michael Peters <[EMAIL PROTECTED]> wrote: > Kasturirangan Rangaswamy wrote: > > 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! > > I think you might be confusing what param() does... I'll elaborate > below... > > > 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'); > > This will set the param for the remainder of this execution cycle. > param() does not set things that are visible across multiple > invocations. > > > > ----------------------------------------------------------- > > > > 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 base? in a script? that really only has meaning inside of a > package > so you don't need that line. > > > 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'; > > same thing... you don't need a 'use base' inside of a script. > > > 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(); > > Why do you think that this run mode would know anything about what > was > set in a different run mode? Yes, your data_entry class now has two > run > modes, 'data_entry_user_details' and 'display_entry_screen' (which it > > inherits from your BASE.pm), but one can't see what happens in the > other, especially on different requests. If you have data you need to > > pass between pages you will need to propagate them using a query > string > or form variables (usually hidden). HTTP (and thus CGI) is a > state-less > environment. After your app sends the page to the user it no-longer > knows the user exists. If you want it to remember the user then you > need > sessions, etc. > > You might try reading the this page on the cgi-app.org wiki which > explains the order of execution for a cgi-app: > http://twiki.med.yale.edu/twiki2/bin/view/CGIapp/OrderOfOperations > > There's also a lot of material on the wiki showing how to process > forms, > use sessions, etc. > -- > Michael Peters > Developer > Plus Three, LP > > __________________________________ Do you Yahoo!? All your favorites on one personal page – Try My Yahoo! 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]