perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xyon <x...@indigorobot.com>
Subject Re: Custom Object-Oriented Module using HTML::Template
Date Thu, 13 Mar 2008 15:01:15 GMT
That worked great with the test script ( print $template->output; ), but
unfortunately, I'm having trouble getting the display onto a web page
(via the Handler). The resulting web page is blank, with no source.


Below are my Apache configs for the handler, logs, and the handler and
view module's latest code. I've also included the test script code, just
in case there is some obvious reason it would work and the handler
won't.




Apache config:
----------------------------------------------------
PerlRequire /etc/httpd/perl/startup.pl
<Location /admin>
    SetHandler modperl 
    PerlResponseHandler Myserver::Handler
</Location>
----------------------------------------------------




/etc/httpd/perl/startup.pl:
----------------------------------------------------
use lib qw(/home/Perl/);
1;
----------------------------------------------------




Apache log:
----------------------------------------------------
==> /var/log/httpd/error_log <==
### HTML::Template Debug ### In _parse:
### HTML::Template _param Stack Dump ###

$VAR1 = [
          \'<html><body bgcolor="#FF00FF">Test!</body></html>
'
        ];

### HTML::Template Debug ### In output
### HTML::Template output Stack Dump ###

$VAR1 = [
          \'<html><body bgcolor="#FF00FF">Test!</body></html>
'
        ];


==> /var/log/httpd/ssl_request_log <==
[13/Mar/2008:10:48:38 -0400] 10.5.5.5 TLSv1 DHE-RSA-AES256-SHA
"GET /admin/ HTTP/1.1" -

==> /var/log/httpd/ssl_access_log <==
10.5.5.5 - - [13/Mar/2008:10:48:38 -0400] "GET /admin/ HTTP/1.1" 200 -
----------------------------------------------------




/home/Perl/Myserver/Handler.pm
----------------------------------------------------
package Myserver::Handler;

#Setup some essentials
use strict;         #strict tolerance for code
use Carp;           #debugging
use diagnostics;    #more debugging
use warnings;       #more debugging

#Handler-related stuff
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::Const -compile => qw(OK);

sub handler {
    my $self        = shift;
    
    my $view        = Myserver::View->new();
    $view->mainpage;

    # Obligatory stuff for the handler
    $self->content_type('text/html');
    return Apache2::Const::OK;

}

1;

----------------------------------------------------




/home/Perl/Myserver/View.pm:
----------------------------------------------------
package Myserver::View;

#Setup some essentials
use strict;         #strict tolerance for code
use Carp;           #debugging
use diagnostics;    #more debugging
use warnings;       #more debugging

#Loadup some needed functions
use HTML::Template;

sub new {
    my $self        = shift;
    return $self;
}

sub mainpage {
    my $self        = shift;
    my $template    = HTML::Template->new(
		filename => '/home/Perl/tmpl/mainpage.tmpl',
                cache => 1,
                debug => 1,
                stack_debug => 1 );
    print "Content-Type: text/html\n\n";
    print $template->output;
    return $self;
}

1;
----------------------------------------------------




/home/Perl/tmpl/mainpage.tmpl:
----------------------------------------------------
<html><body bgcolor="#FF00FF">Test!</body></html>
----------------------------------------------------




/home/Perl/tests/View_mainpage.pl
----------------------------------------------------
#!/usr/bin/perl -w

# Test printing of the main page
print "Main Page..";

#Let's load the view module
use lib "../";
use Myserver::View;
#Now let's load some things that are very handy
use strict;         #strict tolerance for code
use Carp;           #debugging
use warnings;       #more debugging
use diagnostics;    #even more debugging

# Let's create an object
my $view        = Myserver::View->new;

# Now, let's tell View to display the main page
$view->mainpage;

print ".OK";

1;
----------------------------------------------------




On Thu, 2008-03-13 at 13:29 +0800, Foo JH wrote:
> try print $template->output;
> 
> You forgot the print();
> 
> xyon wrote:
> > Hey everyone,
> >
> > Firstly, I apologize I sent the previous email under an incorrect subject line.
> >
> > I am working on my first Object-Oriented project, and have hit a slight
> > snag. I am using HTML::Template to output within the View module, but it
> > never outputs. I don't see any errors in the logs, I just get a blank
> > page. Below is pertinent information including a test script with its
> > output:
> >
> >
> >
> > OS Info:
> > ----------------------------------------------------
> > CentOS release 4.6 (Final)
> > ----------------------------------------------------
> >
> >
> >
> > Package info:
> > ----------------------------------------------------
> > perl-5.8.8-11
> > perl-HTML-Template-2.9-1
> > httpd-2.0.59-1.el4s1.10.el4.centos
> > mod_perl-2.0.3-1.el4s1.3
> > ----------------------------------------------------
> >
> >
> >
> > /home/perl/Myserver/View.pm
> > ----------------------------------------------------
> > package Myserver::View;
> >
> > #Setup some essentials
> > use strict;         #strict tolerance for code
> > use Carp;           #debugging
> > use diagnostics;    #more debugging
> > use warnings;       #more debugging
> >
> > #Loadup some needed functions
> > use HTML::Template;
> >
> > sub new {
> >     my $self        = shift;
> >     return $self;
> > }
> >
> > sub mainpage {
> >     my $self        = shift;
> >     my $template    = HTML::Template->new( filename =>
> > '/home/Perl/tmpl/mainpage.tmpl',
> >             cache => 1,
> >             debug => 1, 
> >             stack_debug => 1 );
> >     print "Content-Type: text/html\n\n";
> >     $template->output;
> >     return $self;
> > }
> >
> > 1;
> > ----------------------------------------------------
> >
> >
> >
> > /home/Perl/tests/View_mainpage.pl
> > ----------------------------------------------------
> > #!/usr/bin/perl -w
> >
> > # Test printing of the main page
> > print "Main Page..";
> >
> > #Let's load the view module
> > use lib "../";
> > use Myserver::View;
> > #Now let's load some things that are very handy
> > use strict;         #strict tolerance for code
> > use Carp;           #debugging
> > use warnings;       #more debugging
> > use diagnostics;    #even more debugging
> >
> > # Let's create an object
> > my $view        = Myserver::View->new;
> >
> > # Now, let's tell View to display the main page
> > $view->mainpage;
> >
> > print ".OK";
> >
> > 1;
> > ----------------------------------------------------
> >
> >
> >
> > /home/Perl/tmpl/mainpage.tmpl:
> > ----------------------------------------------------
> > <html><body bgcolor="#FF00FF">Test!</body></html>
> > ----------------------------------------------------
> >
> >
> >
> > Output with debugging on (as above):
> > ----------------------------------------------------
> > $ tests/View_mainpage.pl 
> > ### HTML::Template Debug ### In _parse:
> > ### HTML::Template _param Stack Dump ###
> >
> > $VAR1 = [
> >           \'<html><body bgcolor="#FF00FF">Test!</body></html>
> > '
> >         ];
> >
> > Main Page..Content-Type: text/html
> >
> > ### HTML::Template Debug ### In output
> > ### HTML::Template output Stack Dump ###
> >
> > $VAR1 = [
> >           \'<html><body bgcolor="#FF00FF">Test!</body></html>
> > '
> >         ];
> >
> > .OK
> > ----------------------------------------------------
> >
> >
> >
> > Output without debugging:
> > ----------------------------------------------------
> > $ tests/View_mainpage.pl 
> > Main Page..Content-Type: text/html
> >
> > .OK
> > ----------------------------------------------------
> >
> >
> >
> >
> >   
> 


Mime
View raw message