Eric Berg wrote:
> 
> Thanks, Mark,
> 
> Actually, I figured it out veeery late last night.  Turns out that I
> was die'ing in setup() because I was trying to create a user object
> there based on the $self->session('user') value as set in
> CGI::Application::Login.  This is a problem because the redirect only
> happens *after* you return from your run mode.
> 
> The problem was that in my run mode -- in this case, my initial method
> of 'menu' -- I needed an instance of my User object, which couldn't
> happen since I didn't have a username.
> 
> Solution:
> 
> 1) Don't die in setup()!
> 
> 2)  return unless $self->session('user'); in run mode
> 
> A thought that I haven't tried is to create a bailout run mode that
> just returns.  If the code in cgiapp_init fails, and I have to set up
> the redirect stuff (the below does work, and does seem to be supported
> by CGI, BTW) to set the run mode to 'bailout' and be done with it.  At
> that time, having set the header_type to 'redirect', I'll be sent off
> nicely to the login script.

I handle basically the same thing in my setup() routine by manipulating
the start_mode:

   %SES = validate_session();

   my $start_mode = $SES{valid_idle} ? $FORM{rm} : 'login';
   $self->start_mode($start_mode);

###

so I'm using the start_mode() a bit unconventionally-- 
instead of using it as a default mode that never changes, 
I set the start_mode every time I pass through setup. 

  -mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to