[cgiapp] Re: Routes and get_current_runmode()

P Kishor punk.kish at gmail.com
Mon Aug 10 23:58:43 EDT 2009


On Mon, Aug 10, 2009 at 7:46 PM, Mark Stosberg<mark at summersault.com> wrote:
>
>> 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 { ...  }
>

Doesn't. Still the same problem.

> I'm just guessing. You can also dump this to check the order
> of what's registered.
>
>    $self->{__INSTALLED_CALLBACKS}
>

I get the following

Installed callbacks: $VAR1 = { 'load_tmpl' => [], 'prerun' => [
'my_prerun' ], 'init' => [] };

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



-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================


More information about the cgiapp mailing list