As I understand it, allow_globals(...) is simply the equivalent of "use vars
...", meaning that you will not get a strictness error if you attempt to use
the named variables in a Mason component. However, that doesn't
automatically set the variables to anything. You can set them using
$interp->set_global(...)
However, I think the problem in your example code is simply that the
$compiler and $interp are not related to each other. In your example, your
$interp object is creating its own private compiler instance (using Mason
defaults), not using the custom $compiler you created. Try it this way:
my $compiler = HTML::Mason::Compiler->new();
$compiler->allow_globals => [qw($session $cookies $dbh $sth $sth2 $ref)];
my $interp = HTML::Mason::Interp->new(
data_dir => '/usr/local/apache2/mason',
compiler => $compiler
);
$interp->exec('/home/app/public_html/bigtip2/session.pl');
I am assuming here that your "session.pl" is actually a Mason component and
not a perl script. I have no idea what happens if you ask Mason to exec() a
perl script, but I doubt anything useful will come of it.
You might also consider passing your variables as arguments in exec()
instead of using globals. It takes fewer lines of code, and it is less
likely to create problems under mod_perl where globals can retain their
values from one request to the next.
Hope that helps!
-Vince
On 10/19/07, Eli Shemer <[EMAIL PROTECTED]> wrote:
>
> Hey there
>
>
>
> I'm a first time Mason user and I have a small question to ask.
>
>
>
> my $interp = HTML::Mason::Interp->new( data_dir =>
> '/usr/local/apache2/mason');
>
> my $compiler = HTML::Mason::Compiler->new();
>
> $compiler->allow_globals => [qw($session $cookies $dbh $sth $sth2 $ref)];
>
> $interp->exec('/home/app/public_html/bigtip2/session.pl');
>
>
>
> Now from inside the session.pl I cannot access the predefined global
> variables.
>
> What options do I have ?
>
> Is there a special way to load them from inside the called script ?
>
>
>
> I require my core(the above) script to be in standard mod_perl form but
> the building blocks(components) are indeed in Mason format.
>
>
>
> Thanks.
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Mason-users mailing list
> Mason-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mason-users
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users