[cgiapp] getter behavior for -start_mode() ?

2009-02-26 Thread Terrence Brannon
sub logout {
my($app)=...@_;

$app-authen-logout;

$app-forward( $app-start_mode ); # would be nice!
}


instead I will declare a lexical variable for the Application package
($start_mode) and use it in both defining the start mode and forwarding to
it.

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] getter behavior for -start_mode() ?

2009-02-26 Thread Michael Peters

Terrence Brannon wrote:


$app-forward( $app-start_mode ); # would be nice!


Are you saying that start_mode() doesn't return the start mode? It should.

--
Michael Peters
Plus Three, LP


#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] getter behavior for -start_mode() ?

2009-02-26 Thread Rhesa Rozendaal

Terrence Brannon wrote:

sub logout {
my($app)=...@_;

$app-authen-logout;

$app-forward( $app-start_mode ); # would be nice!
}


instead I will declare a lexical variable for the Application package
($start_mode) and use it in both defining the start mode and forwarding to
it.


The implementation of start_mode() suggests that this already works, and the 
following test script shows it does. I haven't checked what forward() would do 
if start_mode is a code ref.


Rhesa


use strict;
use warnings;

use Test::More tests = 2;

use CGI::Application;
$ENV{CGI_APP_RETURN_ONLY} = 1;

{
package My::App;
use base qw/CGI::Application/;

sub setup {
my $self = shift;
$self-header_type('none');
$self-start_mode('mode1');
$self-run_modes([qw/ mode1 mode2 /]);
}

sub mode1 { 'mode1' }
sub mode2 {
my $self = shift;
return 'start mode is ' . $self-start_mode;
}
}

my $app = My::App-new;
is $app-run, 'mode1';
$app-mode_param( sub { 'mode2' } );
is $app-run, 'start mode is mode1';
__END__
1..2
ok 1
ok 2

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] getter behavior for -start_mode() ?

2009-02-26 Thread Terrence Brannon
On Thu, Feb 26, 2009 at 11:27 AM, Rhesa Rozendaal p...@rhesa.com wrote:



 it.


 The implementation of start_mode() suggests that this already works,


I see. the docs do not say that:
http://search.cpan.org/~markstos/CGI-Application-4.21/lib/CGI/Application.pm#start_mode()


 and the following test script shows it does. I haven't checked what
 forward() would do if start_mode is a code ref.


it wouldnt be a code ref: the method would return and return a string for
-forward()

I tried to file a bug on rt.cpan.org but encountered an internal server
error.

Thanks for your help.

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####