You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Bill McCabe <df...@mediaone.net> on 2000/06/26 22:13:09 UTC

Mason--Passing references to components

Hi All

I'm converting a mod_perl module-based site to HTML::Mason and have a
question about passing arguments to a component.

my $penuser = $r->connection->user;
my $authzrc = $m->comp( 'authzREPSYS', data_aref=>\@data_refs,
hconnref=>\%hconn, penuser=>$penuser );

With this call I want the component to authzREPSYS to check a users
authorizations from database, fill out the array pointed to by \@data_refs
with the list of those authorizations, and return a boolean to $authzrc to
signify whether the user has any priveleges at all. The documentation says
that one must pass arrays and hashes as refs, which are then automatically
converted. What if I don't want it automatically converted? Is it
sufficient just to have:

<%args>
$data_aref
$hconnref
$penuser
</%args>

in the component instead of:

<%args>
@data_aref
%hconnref
$penuser
</%args>

The code work fine as a subroutine in the mod_perl module, but not as a
Mason component. Any help would be greatly appreciated.

Thanks,
Bill



Re: Mason--Passing references to components

Posted by Bill McCabe <df...@mediaone.net>.
Thanks for the reply. I'm glad to see that Mason handles them in the
expected way. As it turns out, I was handling them correctly, I was simply
chasing a red herring because (I'm new to Mason) I failed to notice that
the line references in the error output were keyed to the file in data/obj
and not my file. Once I sorted that out I immediately saw the real problem.

Bill


At 9:13 AM +0200 6/27/00, Francesc Guasch wrote:
>Bill McCabe wrote:
>>
>> Hi All
>>
>> I'm converting a mod_perl module-based site to HTML::Mason and have a
>> question about passing arguments to a component.
>>
>> my $penuser = $r->connection->user;
>> my $authzrc = $m->comp( 'authzREPSYS', data_aref=>\@data_refs,
>> hconnref=>\%hconn, penuser=>$penuser );
>>
>this works for me, later you declare data:
>
>>
>> <%args>
>> $data_aref
>> $hconnref
>> $penuser
>> </%args>
>
>And remember to use it as refs:
>
>% foreach (@$data_aref) {
>     <% $_ > <br>
>% }
>
>Maybe you'r error is there, make sure you check perldoc perlref
>
>--
> - frankie -




Re: Mason--Passing references to components

Posted by Francesc Guasch <fr...@etsetb.upc.es>.
Bill McCabe wrote:
> 
> Hi All
> 
> I'm converting a mod_perl module-based site to HTML::Mason and have a
> question about passing arguments to a component.
> 
> my $penuser = $r->connection->user;
> my $authzrc = $m->comp( 'authzREPSYS', data_aref=>\@data_refs,
> hconnref=>\%hconn, penuser=>$penuser );
> 
this works for me, later you declare data:

> 
> <%args>
> $data_aref
> $hconnref
> $penuser
> </%args>

And remember to use it as refs:

% foreach (@$data_aref) {
     <% $_ > <br>
% }

Maybe you'r error is there, make sure you check perldoc perlref

-- 
 - frankie -