[cgiapp] Patch for cgi-app __get_body

Mark Stosberg mark at summersault.com
Wed Mar 24 10:23:29 EDT 2010


Thanks for the idea, Lyle.

I'd like to see what feedback others have before considering it further.

   Mark

On Wed, 17 Mar 2010 23:06:00 +0000
Lyle <webmaster at cosmicperl.com> wrote:

> Hi All,
>   I've found myself overloading this method so that cgi-app runmodes can 
> be chained objects, such as $c->obj->method();
> I've updated the code* so that it shouldn't effect the way everyone is 
> currently doing runmodes:-
> 
> Basically, the lines:-
>     my $body;
>     eval {
>         $body = $is_autoload ? $self->$rmeth($rm) : $self->$rmeth();
>     };
> 
> Are swapped for:-
> 
>     if(ref($rmeth) ne 'ARRAY'){
>         $rmeth=[$rmeth];
>     }
>     my $body=$self;
>     eval {
>         for my $part(@$rmeth){
>             $body=$body->$part($is_autoload ? $rm : ());
>         }
>     };
> 
> 
> So if the runmode is passed in as an array reference then the methods 
> are chained one after the other. Potentially this allows for any depth, 
> so a runmode may refer to:-
> $c->obj1->obj2->obj3->method(), etc, where objX are just methods that 
> return objects.
> 
> Rather than just submitting a patch direct to Mark, I thought I'd post 
> it here to check that this wouldn't create any problems for anyone.


-- 
 . . . . . . . . . . . . . . . . . . . . . . . . . . . 
   Mark Stosberg            Principal Developer  
   mark at summersault.com     Summersault, LLC     
   765-939-9301 ext 202     database driven websites
 . . . . . http://www.summersault.com/ . . . . . . . .




More information about the cgiapp mailing list