> A simple handler might look like this.  Check the site docs for
> more info.
>
> -----
> package My::ApacheHandler;
> use strict;
> use HTML::Mason::ApacheHandler;
>
> my $ah = HTML::Mason::ApacheHandler->new(
>   comp_root => '/webdata/',
>   data_dir => '/var/mason',
>   error_mode => 'fatal',
>   allow_globals => [ qw( %SESSION ) ],
> );
>

I ran into an interesting 'gotcha' with this, maybe someone with more
experience than me can point out a solution.

I first started with the version here:
http://www.masonhq.com/docs/manual/Admin.html#writing_a_wrapper and
got that working and then added the addtions from the above example.

When I try and do an 'untie %session' I get this nasty error in the logs:

Global symbol "%session" requires explicit package name at
/var/www/html/lib/Handler.pm line 33.\nCompilation failed in require
at /var/www/startup.pl line 55.

So the %session is out of scope when I try and untie it in the handler.

I tried using only the ' PerlSetVar MasonAllowGlobals %session' in
httpd.conf but that did not work.

Any ideas?

Here is my handler:
package MyApp::Mason;
use strict;
use HTML::Mason::ApacheHandler;
my $ah =
    HTML::Mason::ApacheHandler->new
      ( comp_root => '/var/www/html',
        data_dir  => '/var/www/mason.data',
        allow_globals => [qw(%session $dbh $sess_dbh $log)], );

sub handler {
    my ($r) = @_;

    my $result = eval {
        $ah->handle_request($r);
    };

    if (my $err = $@) {
        # log error here
    }
    untie(%session);
    return($result);
}

1;

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to