Discussion:
[cgi-prototype-users] interstitial method issue
Tom Adamo
2006-09-05 14:27:39 UTC
Permalink
I've been playing around with the interstitial method a bit and it's working
well for me. But, I've run into an issue where I need to bust out of the
steps. Has any thought been given on how to do this?

For example:

my $p = $self->interstitial(
{ message => "Doing 1st thing...",
action => sub {
$self->do_first_thing();
},
},
{ message => "Doing 2nd thing...",
action => sub {

### Something goes wrong here ....
$self->do_second_thing();

},
},
{ message => "Doing 3rd thing...",
action => sub {
$self->do_third_thing();
},
},
);
return $p if $p;


If something goes on it step 2 and I don't want to proceed to step 3, how do
I do that?


One idea I had was that the interstitial method could check the result of
the given action, and if there is a result, return it. That way my action
could return a page object and I could send the user to any page I want.

For example:

change:
if ($step >= 1 and $step <= @steps) { # we got work to do
if (defined (my $code = $steps[$step - 1]{action})) {
$code->(); # run the action
}
}

to:
if ( $step >= 1 and $step <= @steps ) { # we got work to do
if ( defined( my $code = $steps[ $step - 1 ]{action} ) ) {
my $action_result = $code->(); # run the action
if ($action_result) {
$self->CGI->delete($cip);
return $action_result;
}
}
}


Any thoughts on this?

Thanks for the help!
--
Tom Adamo
Randal L. Schwartz
2006-09-07 14:23:20 UTC
Permalink
Tom> One idea I had was that the interstitial method could check the result of
Tom> the given action, and if there is a result, return it. That way my action
Tom> could return a page object and I could send the user to any page I want.

That's a great idea. Might be enough for me to incorporate and get a new
release out as well (I've got a couple of minor buggy things that I'm saving
up too).
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<***@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Loading...