On Mon, 14 Mar 2005 12:17:43 -0500, Michael Peters
<[EMAIL PROTECTED]> wrote:
> Tony Fraser wrote:
> > Attached is a patch that applies cleanly to CGI::Application version
> > 3.31. The patch adds a bounce("runmode_name") method to CGI::Application
> >
> > The idea behind the bounce() method is to hopefully standardize the way
> > we change run modes. Have a look at the sample code snippet of a
> > CGI::Application sub-class:
> 
> I like the idea, but not necessarily the name. Maybe jump() or goto() or
> goto_rm() would be better? This would also provide a way to cleanly
> change the value of get_current_runmode() to the new run mode. What do
> others think?

I agree with the idea that 'bounce' might not be a good name, but I
have to say that anything with 'goto' in it is even worse, since
'goto' has an implied meaning in programming, and in this case it
doesn't match up (we return to the location where the call was made,
wheras a standard goto never comes back).

Of course it is easy to complain, but more difficult to come up with a
solution ;).  I can't think of a good name right now....  Maybe just
as simple as 'call' or 'call_runmode'.

> > +     $self->{__CURRENT_RUNMODE} = $old_rm;
> 
> Why is there a need to restore the value of the old run mode? Wouldn't
> this be confusing if say someone writes a cgiapp_postrun() method to do
> something based on the run mode? If someone 'jumped' from A -> B, it
> would seem more natural that the postrun think they are in run mode B,
> not A.

It brings up an interesting dilema (which is maybe why Jesse
originally stayed away from this).  I could argue this both ways... 
What is stopping someone from doing the following, and what should the
runmode be set to in this case?

sub my_runmode {
  my $self = shift;

  my $html = $self->bounce->('other_runmode');
  if !$html return 'something else';
  return $html;
}

Perhaps the chain of runmodes should be kept in an array, where the
first element is the most recent runmode to run.  Then we return only
the first element if get_current_runmode() is called in scalar
context, and return all the runmodes if called in array context.

I'm not sure what that would gain you though, because you still don't
know which runmode was the one that actually generated the data...

> Even if the general consensus is that this should not be a part of C::A,
>   it would still make a nice plugin :)

That is probably the best place for this to start...

Cheers,

Cees

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to