[cgiapp] Patch for cgi-app __get_body
Cees Hek
ceeshek at gmail.com
Fri Apr 9 00:26:58 EDT 2010
On Sat, Apr 3, 2010 at 3:11 AM, Lyle <webmaster at cosmicperl.com> wrote:
> Bump, does anyone have objections to this? I can't see that it'll effect
> anyones code.
Hi Lyle,
It would help if you explain how you actually use this and why it is
beneficial. It doesn't look like something that I would use, but
maybe that is just because I can't see a good use for it.
Also, It seems a bit dangerous to me in it's current form as you
assume that the runmodes will return an object except for the last one
which returns content. Shouldn't you check to make sure an object was
actually returned before arbitrarily calling methods on it? And what
do you do if content is returned too early instead of an object? Do
you just short circuit the execution and just return that content or
do you throw an error?
Cheers,
Cees
>
>
> Lyle
>
> Mark Stosberg wrote:
>> 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.
>>>
>>
>>
>>
>
> ##### CGI::Application community mailing list ################
> ## ##
> ## To unsubscribe, or change your message delivery options, ##
> ## visit: http://lists.openlib.org/mailman/listinfo/cgiapp ##
> ## ##
> ## Web archive: http://lists.openlib.org/pipermail/cgiapp/ ##
> ## Wiki: http://cgiapp.erlbaum.net/ ##
> ## ##
> ################################################################
>
>
More information about the cgiapp
mailing list