[cgiapp] Re: Routes and get_current_runmode()

Mark Stosberg mark at summersault.com
Mon Aug 10 20:46:28 EDT 2009


> See what is going on -- C::A::P::Routes correctly thinks the runmode
> is ‘mainpage’ as per the URL. However, $self->get_current_runmode()
> returns ‘welcome’ in cgiapp_prerun(), and as a result, the mainpage is
> not protected. Now, it could be that C::A::P::Routes is firing *after*
> my cgiapp_prerun() protected_mode logic is run. To test that, I
> uncommented the #$self->prerun_mode('login'); line in cgiapp_prerun(),
> and lo and behold, the runmode is changed to login.

I agree with you assessment of where the problem is. 

> The remedy seems to be that once it has figured out the runmode
> correctly, C::A::P::Routes should set the value of
> $self->get_current_runmode() to it.
> 
> If I have diagnosed the problem correctly, please help me find a fix.
> If not, please help me diagnose correctly.

My suggestion for a fix is to see about getting the the routes prerun
before and your prerun behavior to trigger in the other order. 

<scratches head>

maybe this will help?: 

Instead of: 

    sub cgiapp_prerun { ...  }

Try

 __PACKAGE__->add_callback( prerun => 'my_prerun' );
 sub my_prerun { ...  }

I'm just guessing. You can also dump this to check the order
of what's registered.

    $self->{__INSTALLED_CALLBACKS}

    Mark

-- 
http://mark.stosberg.com/





More information about the cgiapp mailing list