You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Timothy K Lu <ti...@MIT.EDU> on 2000/02/17 01:16:20 UTC

Mason prints out ApacheHandler object

session_handler.pl
******************

package HTML::Mason;

use HTML::Mason;
use strict;

{  package HTML::Mason::Commands;
   use vars qw(%session);
   use CGI::Cookie;
   use Apache::Session::File;
}

my $parser = new HTML::Mason::Parser;
my $interp = new HTML::Mason::Interp (parser=>$parser,
                                      comp_root=>'/home/www',
                                      data_dir=>'/opt/mason_data');
my $ah = new HTML::Mason::ApacheHandler (interp=>$interp,auto_send_headers=>undef);

chown ( [getpwnam('nobody')]->[2], [getgrnam('nogroup')]->[2],
        $interp->files_written );

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

    return -1 if $r->content_type && $r->content_type !~ m|^text/|io;

    my %cookies = parse CGI::Cookie($r->header_in('Cookie'));

    eval {
      tie %HTML::Mason::Commands::session, 'Apache::Session::File',
        ( $cookies{'AF_SID'} ? $cookies{'AF_SID'}->value() : undef );
    };

    if ( $@ ) {
      # If the session is invalid, create a new session.
      if ( $@ =~ m#^Object does not exist in the data store# ) {
        tie %HTML::Mason::Commands::session, 'Apache::Session::File', undef;
        undef $cookies{'AF_SID'};
      }
    }

    if ( !$cookies{'AF_SID'} ) {
      my $cookie = new CGI::Cookie(-name=>'AF_SID', -value=>$HTML::Mason::Commands::session{_session_id}, -path => '/',);
      $r->header_out('Set-Cookie', => $cookie);
    }

    my $status = $ah->handle_request($r);

    untie %HTML::Mason::Commands::session;

    return $status;
}

1;


my test page
*************
<HTML>
<HEAD>
<TITLE>Testing</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>

<BODY>
% print $m;
% my $test = "hello";

superman <% $test %>

</BODY>
</HTML>


>Somehow you are printing out the ApacheHandler object. Could you post
>the contents of handler.pl and your page?

At 03:55 PM 2/16/00 -0500, Timothy K Lu wrote:
>>Hello,
>>
>>I am just beginning to test out Mason.
>>I have written a short HTML file with embedded perl in it but when I load
>>up the page in Netscape, I get this splashed to the screen:
>>
>>HTML::Mason::Request::ApacheHandler=HASH(0x860d368)HTTP/1.1 200 OK >>Date:
>>Tue, 15 Feb 2000 20:23:28 GMT Server: Apache/1.3.11 (Unix) mod_perl/1.21
>>mod_ssl/2.5.0
>>OpenSSL/0.9.4 Connection: close Content-Type: text/html
>>
>>Therefore, I did
>>
>>my $ah = new HTML::Mason::ApacheHandler
>> (interp=>>$interp,auto_send_headers=>>undef);
>>
>>in eg/session_handler.pl and the only thing I had printed out was then:
>>
>>HTML::Mason::Request::ApacheHandler=HASH(0x86a58c0)
>>
>>How do I get rid of that?
>>
>>This does not seem to happen in IE.  I didn't even need to assign
>>auto_send_headers to undef for this to work in IE.
>>
>>Can anyone help me out?
>>
>>Thanks.
>>
>>Tim
>>
>>_______________________________________________
>>Mason maillist  -  Mason@netizen.com.au
>>http://netizen.com.au/mailman/listinfo/mason
>>

Re: Mason prints out ApacheHandler object

Posted by Tim Lu <ti...@MIT.EDU>.
argh, stupid me...

thanks.

tim

At 07:57 PM 2/16/00 -0800, you wrote:
>You are printing out the Mason request object, $m.
>
>% print $m;
>
>What did you intend for this line to do?



Re: Mason prints out ApacheHandler object

Posted by Jonathan Swartz <sw...@transbay.net>.
You are printing out the Mason request object, $m.

% print $m;

What did you intend for this line to do?