Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: mod_perl & ajax

by artemave (Beadle)
on Apr 11, 2007 at 10:56 UTC ( [id://609333]=note: print w/replies, xml ) Need Help??


in reply to Re: mod_perl & ajax
in thread mod_perl & ajax

You are right.
But the errors produced by Error.pm seem to be irrelevant.
Ok, I'll post the workable code without Ajax and the same after putting some. Here we go:
package dir_browse::dir_browse; use strict; use warnings; use Apache2::RequestRec; use Apache2::RequestIO; use Apache2::Const qw(:common); use Apache2::Reload; use File::Spec; use Error qw(:try); use Template; sub new { bless {} } sub handler : method { my ($self, $r) = @_; $Error::Debug = 1; $self = $self->new unless ref $self; $self->{r} = $r; try { my $websrc = $self->get_websrc; my $template = new Template({ INCLUDE_PATH => ["$websrc/src", "$websrc/lib"], INTERPOLATE => 1, OUTPUT => $self->{r}, }); $self->get_contents(File::Spec->rel2abs($self->{r}->path_info) +); $self->{r}->content_type('text/html'); throw Error(-text => "No path '$websrc'") unless -f "$websrc/s +rc/dir_browse.tt2"; $template->process('dir_browse.tt2', $self) or throw Error(text => $template->error()); } catch Error with { my $E = shift; $self->{r}->print($E->stacktrace); $self->{r}->log_error($E->stacktrace); return Apache2::Const::SERVER_ERROR; }; return Apache2::Const::OK; } ... 1;
Now the one with Ajax:
package dir_browse::dir_browse; use strict; use warnings; use Apache2::RequestRec; use Apache2::RequestIO; use Apache2::Const qw(:common); use Apache2::Reload; use Apache2::Ajax; use File::Spec; use Error qw(:try); use Template; sub new { bless {} } sub handler : method { my ($self, $r) = @_; $Error::Debug = 1; $self = $self->new unless ref $self; $self->{r} = $r; try { my $websrc = $self->get_websrc; my $template = new Template({ INCLUDE_PATH => ["$websrc/src", "$websrc/lib"], INTERPOLATE => 1, OUTPUT => $self->{r}, }); $self->get_contents(File::Spec->rel2abs($self->{r}->path_info) +); $self->{r}->content_type('text/html'); throw Error(-text => "No path '$websrc'") unless -f "$websrc/s +rc/dir_browse.tt2"; my $html; $template->process('dir_browse.tt2', $self, \$html) or throw Error(text => $template->error()); my $ajax = Apache2::Ajax->new($self->{r}, 'show' => sub {retur +n $html}) or throw Error(text => "DARN!! "); $self->{r}->print($ajax->build_html()); } catch Error with { my $E = shift; $self->{r}->print($E->stacktrace); $self->{r}->log_error($E->stacktrace); return Apache2::Const::SERVER_ERROR; }; return Apache2::Const::OK; } ... 1;
And the httpd.confL
PerlModule Apache2::Ajax ... PerlModule Apache2::dir_browse <Location /dir_browse> SetHandler perl-script PerlResponseHandler dir_browse::dir_browse </Location>
And here is the error message I get when I rum this:
Can't locate Apache2/Request.pm in @INC (@INC contains: C:\Program Files\ActiveState Perl Dev Kit 6.0\lib\ C:\cygwin\home\artem\perl_projects\web c:/Perl/site/lib c:/Perl/lib . C:/Program Files/Apache Software Foundation/Apache2.2) at c:/Perl/site/lib/Error.pm line 38 Error::throw_Error_Simple('HASH(0xc5f508)') called at c:/Perl/site/lib/Error.pm line 297 Error::subs::run_clauses('HASH(0xc5f4b4)', 'Can\'t locate Apache2/Request.pm in @INC (@INC contains: C:\P...', 'undef', 'ARRAY(0xc99978)') called at c:/Perl/site/lib/Error.pm line 416 Error::subs::try('CODE(0x107b1b0)', 'HASH(0xc5f4b4)') called at C:\cygwin\home\artem\perl_projects\web/dir_browse/dir_browse.pm line 55 dir_browse::dir_browse::handler('dir_browse::dir_browse', 'Apache2::RequestRec=SCALAR(0x107b15c)') called at -e line 0 eval {...} called at -e line 0

I'm using the latest mod_perl2, ActiveState 5.8.8.819, WinXP SP2.

Thanks a lot,
Artem.

Replies are listed 'Best First'.
Re^3: mod_perl & ajax
by randyk (Parson) on Apr 11, 2007 at 17:59 UTC
    One place that Apache2::Request is used is in CGI::Apache2::Wrapper, which Apache2::Ajax will use if available. If you've installed CGI-Apache2-Wrapper, did you also install libapreq2 (which provides Apache2::Request)?
      That is true. I didn't notice the message that I would need to install libapreq2 separetely when I was installing CGI-Apache2-Wrapper.
      The problem now is that I can't install libapreq2.
      nmake says:
      D:\dst\ActivePerl\libapreq2-2.08>nmake Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. NMAKE /nologo /f D:\dst\ACTIVE~1\LIBAPR~1.08\win32\libapreq2.m +ak CFG="li bapreq2 - Win32 Release" APACHE="C:\PROGRA~1\APACHE~1\Apache2.2" APREQ +_HOME="D:\ dst\ACTIVE~1\LIBAPR~1.08" APR_LIB="C:\PROGRA~1\APACHE~1\Apache2.2\lib\ +libapr-1.l ib" APU_LIB="C:\PROGRA~1\APACHE~1\Apache2.2\lib\libaprutil-1.lib" cl.exe /Fo"D:\dst\ACTIVE~1\LIBAPR~1.08\win32\libs\cookie.obj" +/nologo /M D /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" + /I"C:\PRO GRA~1\APACHE~1\Apache2.2\include" /I"C:\Program\ Files\Microsoft\ Plat +form\ SDK\ for\ Windows\ Server\ 2003\ R2\Include" /I"D:\dst\ACTIVE~1\LIBAPR~1.0 +8\include" /YX /FD /c D:\dst\ACTIVE~1\LIBAPR~1.08\library\cookie.c cl : Command line warning D9002 : ignoring unknown option '/YX' cookie.c c:\program files\apache software foundation\apache2.2\include\apr.h(92 +) : fatal error C1083: Cannot open include file: 'windows.h': No such file or di +rectory NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code + '0x2' Stop. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code + '0x2' Stop.
      In fact, there is such a header in C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include (which I included manually in libapreq2.mak).

      Don't know what to do.
      Artem.

      !!!!!!!!!!!!!!! THE ABOVE IS SOLVED !!!

      Just install libapreq2 from ppm... So easy.
      hi.. following error occured when I run it on web Is Apache2::Request is not working in Apache2 ? package test::showupload; use Apache2::Request; sub handler { my $req = shift; my $r = Apache2::Request->new($req); $r->content_type('text/html'); print <<EOF; <html>

      Hello

      </html> EOF return Apache2::Const::OK; } 1; result -- nothing will appear on web please give me solution...
Re^3: mod_perl & ajax
by ides (Deacon) on Apr 11, 2007 at 16:06 UTC

    Hmmm, it appears something in your code is trying to use Apache2::Request ( aka libapreq2 not to be confused with Apache2::RequestRec, etc. ).

    Give this a try, "use Apache2::Ajax;" in your code, but don't actually call any of it's methods, etc. See if you can just load it up without getting that error.

    Frank Wiles <frank@revsys.com>
    www.revsys.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://609333]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-25 19:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found