Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TestCGIApplication;
- use base 'CGI::Application';
- use CGI::Application::Plugin::TT;
- use CGI::Application::Plugin::Session;
- use Template;
- use CGI::Application::Plugin::LogDispatch;
- use strict;
- my $global_session;
- my @parameter_list = ("session_id","t1","t2","cbox");
- our $TEMPLATE_OPTIONS = {
- INCLUDE_PATH => \@INC,
- };
- TestCGIApplication->tt_config( TEMPLATE_OPTIONS => $TEMPLATE_OPTIONS );
- sub setup {
- my $self = shift;
- #$self->tmpl_path('/Library/WebServer/Documents/XXXXXX/cgi-bin/tt/');
- $self->start_mode('mode1');
- $self->run_modes({
- 'mode1' => 'collect_data',
- 'mode2' => 'display_data'
- });
- }
- sub cgi_app_init(){
- my $self = shift;
- $self->session_config(
- CGI_SESSION_OPTIONS => [
- undef,
- $self->query,
- { Directory => '/tmp/sessions' }
- ]) or die $!;
- $self->log_config(
- LOG_DISPATCH_MODULES => [
- {
- module => 'Log::Dispatch::File',
- name => 'info',
- filename => 'info.log',
- min_level => 'info',
- close_after_write => 'false',
- },
- ]) or die $!;
- }
- sub error(){
- return $!;
- }
- sub collect_data(){
- my $self = shift;
- $global_session = $self->session();
- my $query = $global_session->query();
- my %page_data;
- $self->log->info(sprintf "\ncollect_data() cbox=:%s:",$query->param('cbox'));
- if(!$global_session->is_new()){
- $global_session->clear();
- %page_data = ('session_id' => $global_session->id(),
- 't1' => $query->param('t1'),
- 't2'=> $query->param('t2'),
- 'cbox' => $query->param('cbox')
- );
- $global_session->save_param();
- }else {
- %page_data = ('session_id' => $global_session->id(),
- 't1' => $query->param('t1'),
- 't2'=> $query->param('t2'),
- 'cbox' => $query->param('cbox')
- );
- }
- #$global_session->load_param($query,\@parameter_list);
- return $self->tt_process('collect_data.tt',\%page_data);
- }
- sub display_data(){
- my $self = shift;
- $global_session = $self->session;
- my $query = $global_session->query();
- my %page_data = ('session_id' => $global_session->id(),
- 't1' => $query->param('t1'),
- 't2'=> $query->param('t2'),
- 'cbox' => $query->param('cbox')
- );
- $self->log->info(sprintf "\ndisplay_data() cbox=:%s:",$query->param('cbox'));
- $global_session->save_param($query,\@parameter_list);
- # $global_session->save_param();
- return $self->tt_process('display_data.tt',\%page_data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement