[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cgiapp] problem with prerun_mode()


Hi Michael,

That seems like a strange behavior, but it might be caused by the Vars()
function. But, I never use it. Rather I use param() which will return a
list of all names (keys).

I used the follow code as a test app (run from the command line):

--- 8< -------

package MyApp;

use strict;
use base 'CGI::Application';

sub setup {
	my $self = shift;
	$self->start_mode( 'modestart' );
	$self->mode_param( 'rm' );
	$self->run_modes(
		'modestart' => 'modestart',
		'modeadd'   => 'modeadd',
	);
}

sub cgiapp_prerun {
	my $self = shift;
	my $q    = $self->query;

	# print query data
	for my $key ( sort $q->param ) {
		print "$key = " . $q->param( $key ) . "\n";
	}

	# switch run modes
	if ( $q->param( 'x' ) ) {
		print "switched modes\n";
		$self->prerun_mode( "modeadd" );
	}
}

sub modestart {
	return "mode: start\n";
}

sub modeadd {
	my $self = shift;
	my $q    = $self->query;

	# print query data
	for my $key ( sort $q->param ) {
		print "$key = " . $q->param( $key ) . "\n";
	}

	return "mode: add\n";
}

1;

--- 8< -------

Here's the default output:

C:\>perl i.pl
Content-Type: text/html; charset=ISO-8859-1

mode: start

Here's the output including one parameter:

C:\>perl i.pl y=2
y = 2
Content-Type: text/html; charset=ISO-8859-1

mode: start

Here's the output when switching modes including several parameters:

C:\>perl i.pl x=1 y=2 z=3
x = 1
y = 2
z = 3
switched modes
x = 1
y = 2
z = 3
Content-Type: text/html; charset=ISO-8859-1

mode: add

So, it seems to work okay. =)

HTH,

-Brian Cassidy

> -----Original Message-----
> From: Michael Hirmke [mailto:suppressed
> Sent: Tuesday, July 15, 2003 3:08 PM
> To: suppressed
> Subject: [cgiapp] problem with prerun_mode()
> 
> Hi *,
> 
> I tried to find a solution for my problem in the history of the list,
> but didn't get anything.
> When I modify the runmode within cgiapp_prerun using the prerun_mode
> function, it seems that the query object somehow gets destroyed or at
> least doesn't contain the previous params, when entering this new
> runmode function.
> At the beginning of cgiapp_prerun I loop through all the params of the
> CGI object and find them all set to the proper values. At the
beginning
> of the function the new runmode points to, all of my params seem to be
> gone.


http://www.gordano.com - Messaging for educators.

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.