[cgiapp] Re: order of operations

P Kishor punk.kish at gmail.com
Wed Aug 12 21:56:29 EDT 2009


On Wed, Aug 12, 2009 at 5:50 PM, Ron Savage<ron at savage.net.au> wrote:
> Hi Puneet
>
> On Wed, 2009-08-12 at 12:07 -0500, P Kishor wrote:
>> > 1. sub setup {
>> >    my $self = shift;
>> >    $self->SUPER::setup();
>> >    $self->run_modes([qw( welcome view )]);
>> >    $self->start_mode('welcome');
>> >    $self->param(protected_runmodes => [qw(view)]);
>>
>>
>> The above line re-declares the protected_runmodes param, so all the
>> protected_runmodes set in MyAuthen vanish and we left with only 'view'
>> as a protected_runmode. The following code corrects the situation
>>
>> my $protected_runmodes = $self->param('protected_runmodes');
>> push @$protected_runmodes, 'view';
>
> All that does is store the run modes in an array local to the sub.
>
> It does /not/ pass the updated list back to whatever object manages
> these things.
>

correct... that is because in my excitement I posted only half the
code. I do the following

in the base class

sub setup {
  $self->_protected_runmodes([qw(r1 r2 r3)]);
}

and nearby

sub _protected_runmodes {
    my $self = shift;
    my $runmodes = shift;

    my $protected_runmodes = $self->param('protected_runmodes');
    push @$protected_runmodes, @$runmodes;
    $self->param('protected_runmodes' => $protected_runmodes);
}

then, in inherited class I can do

sub setup {
  my $self = shift;
  $self->SUPER::setup();
  $self->_protected_runmodes([qw(r4)]);
}

and I get r4 added to the list of protected runmodes.

It all works, at least for now.





-- 
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
=======================================================================
Sent from Madison, WI, United States


More information about the cgiapp mailing list