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

Re: [cgiapp] Q: get_current_runmode() after changing runmodes


On Thu, 24 Jul 2003 18:55:28 +0200, suppressed wrote:

Hi Marcus

>sub radl_address {              # first runmode
>...
>unless ($address_errors) {
>return $self->browsemap;    # this is the new runmode
>}
>}
>
>For status saving into session objects I need the name of the 
current
>runmode, which can be obtained by calling 
$self->get_current_runmode,
>but this (obviously) doesn't give the name of the final runmode but
>the name of the first one.
>
>Is there any solution without introducing an extra parameter which
>carries along the name of the runmode?

I see Steve has given one solution, but I think he's overlooked 
something.

The real problem is a design fault: Your real run mode is browsemap. 
You code should have entered there, not via radl_address.

In sub setup I put:
	$self -> mode_param(\&setup_mode);

Then:
sub setup_mode
{
...
	elsif ($run_mode =~ /(save|update)_(.+)/) # ie /browsemap/
	{
		$mode	= $1;
		$kind	= $2;
		$key	= ${$self -> param('key')}{$kind};
		$method	= "validate_$kind";

		for (keys %$key)
		{
			$self -> param($_, $self -> clean_user_data($self -> query() -> 
param($_), $$key{$_}{'size'}, length($$key{$_}{'default'}) ) );
		}

		$self -> $method($run_mode);

		$run_mode = ( ($mode eq 'save') ? 'add' : 'edit') . "_$kind" if 
($self -> param('error') );
	}

	$run_mode;

}	# End of setup_mode.

which means I enter and exit this sub in what you would call 
browsemap, or, if there was an error, enter in mode browsemap and 
exit in 'fix error' mode...

-- 
Ron Savage, suppressed on 25/07/2003. Room EF 312
Deakin University, 221 Burwood Highway, Burwood, VIC 3125, Australia
Phone: +61-3-9251 7067, Fax: +61-3-9251 7604
http://www.deakin.edu.au/~rons



---------------------------------------------------------------------
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.