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

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


completely untested and on a friday afternoon (atleast for me, because i'm
taking tomorrow off) here's some code you could use instead of return
$self->some_run_mode();

sub pipe_rm
{
    my $self    = shift;
    my $rm    = shift;
    $self->param( '_last_rm_executed' => $rm );
    return eval { $self->$rm };
}

you could put that routine in your baseclass and then when you wanted to
pipe a runmode you would call

return $self->pipe_rm( 'some_run_mode' );

and if you wanted to know what the last rm to be piped was you could call

$self->param( '_last_rm_executed' );

not the CLEANEST solution in the world, but hey, atleast i had a disclaimer
at the top ;)

obviously this solution eliminates the ability to pass arguments to a
run-mode (which is something i rarely if ever do, and actually try to aviod
it with extreme prejudice). but that's not to say you couldn't add that
functionality to pipe_rm if you REALLY needed it.

> Is there any solution without introducing an extra parameter which
> carries along the name of the runmode?

oh, i guess i didn't really read your question. WITHOUT introducting an
extra parameter. i don't think so, but atleast this way you won't have to
remember to add that $self->param( 'name' => 'value' ) line to the top of
every run-mode.

but hey if you really wanted to hack with the C::A core, not that i'm
suggesting you do, change the line in pipe_rm from
$self->param('_last_rm_executed' => $rm ) to $self->{__CURRENT_RUNMODE}= $rm
and then you'd be able to use $self->get_current_runmode() to access the
value. i'm just not promising that doing so won't fuck something up later ;)
use with extreme caution.


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