Re: Problem getting started
Please include the list on replies, so the archives are complete.
Quoting "John M. Dlugosz" <l3hc4oo02@sneakemail.com>:
[color=blue]
> Adam Prime adam.prime-at-utoronto.ca |mod_perl mailing list| wrote:[color=green]
>> For the Apache2::Request problem you're running:
>>
>> use Apache2::Request;
>> $req = Apache2::Request->new($r);
>> @foo = $req->param("foo");
>> $bar = $req->args("bar");
>>
>> and getting a segfault on new?[/color]
>
> If I reduce it down to the first two lines only, I get the segfault.
> If I reduce it to the first line only, I don't.
>
>[color=green]
>> Are you running this as a handler, or through one of the CGI
>> emulation layers (ModPerl::PerlRun, or ModPerl::Registry for
>> example). you do[/color]
>
> ModPerl::Registry.
>
> In my apache2.conf file:
>
> PerlModule ModPerl::Registry
>
> <Location "/modperl/">
> SetHandler perl-script
> PerlHandler ModPerl::Registry
> Options +ExecCGI
> PerlSendHeader On
> Allow from all
> </Location>
>
> Hmm, is there a way to find out whether these settings are applying to
> the directory I think it is? /modperl/ should be applied to each
> DocumentRoot, right?
>[/color]
correct.
[color=blue][color=green]
>> also have
>>
>> my $r = shift;
>>
>> somewhere above that (and ideally use strict; as well) right?[/color]
>
> No, just what it shows in the example.[/color]
This is your problem. Apparently if you call Apache2::Request->new
with an undefined object, it segfaults.
i ran this:
use Apache2::Request;
my $req = Apache2::Request->new($r);
print qq[Content-type: text/html\n\n];
print q[hi];
through registry, and saw
[Sat Jul 12 22:58:58 2008] [notice] child pid 5703 exit signal
Segmentation fault (11)
If you change that to
use Apache2::Request;
my $r = shift;
my $req = Apache2::Request->new($r);
print qq[Content-type: text/html\n\n];
print q[hi];
it should work. Unfortunately, it looks like the documentation for
ModPerl::Registry is kind of lacking on perl.apache.org, but what is
there is at
[url]http://perl.apache.org/docs/2.0/api/ModPerl/Registry.html[/url]
Adam
Re: Problem getting started
[color=blue]
> This is your problem. Apparently if you call Apache2::Request->new
> with an undefined object, it segfaults.
>
> i ran this:
>
> use Apache2::Request;
> my $req = Apache2::Request->new($r);
> print qq[Content-type: text/html\n\n];
> print q[hi];
>
> through registry, and saw
>
> [Sat Jul 12 22:58:58 2008] [notice] child pid 5703 exit signal
> Segmentation fault (11)
>
> If you change that to
>
> use Apache2::Request;
> my $r = shift;
> my $req = Apache2::Request->new($r);
> print qq[Content-type: text/html\n\n];
> print q[hi];
>
> it should work. Unfortunately, it looks like the documentation for
> ModPerl::Registry is kind of lacking on perl.apache.org, but what is
> there is at
> [url]http://perl.apache.org/docs/2.0/api/ModPerl/Registry.html[/url]
>
> Adam
>[/color]
OK, when I defined $r as you did, it worked. For documentation, I was
looking at here:
<http://search.cpan.org/~joesuf/libapreq2-2.08/glue/perl/lib/Apache2/Request.pm>
I see you are just printing to standard output, like a CGI script. In
the book, it used
$r->send_http_header('text/plain');
$r->print("mod_perl rules!\n");
but there are no such methods on $r here in 2.0.
What, prey tell, is the equivalent object?
Is there =any= way to get started, like a simple (but working!) program
I could look at?
--John
Re: Problem getting started
Hi John,
John M. Dlugosz wrote:[color=blue]
> OK, when I defined $r as you did, it worked. For documentation, I was
> looking at here:
> <http://search.cpan.org/~joesuf/libapreq2-2.08/glue/perl/lib/Apache2/Request.pm>
>
>
> I see you are just printing to standard output, like a CGI script. In
> the book, it used
>
> $r->send_http_header('text/plain');
> $r->print("mod_perl rules!\n");
>
> but there are no such methods on $r here in 2.0.
>
> What, prey tell, is the equivalent object?
> Is there =any= way to get started, like a simple (but working!)
> program I could look at?[/color]
When I was starting with modperl2, I had similar problems to you. I'm
more of a book-person, and many of the books (such as the O'Reilly ones)
have not been re-released for modperl2. While there is a lot of
information on the web, it isn't as easy sifting through it all.
As for your question, the $r object is (I believe :-) ) the RequestRec
object:
[url]http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html[/url]
and instead of send_http_header, you would use content_type. As
mentioned here which describes porting mod_perl 1.0 to mod_perl 2.0:
[url]http://perl.apache.org/docs/2.0/user/porting/compat.html#C__r_E_gt_send_http_header_[/url]
You may need to use these two documents (at least) in conjunction with
the book you are reading to make any sense of it. Hope this helps!
Ray
Re: Problem getting started
On Sun, Jul 13, 2008 at 1:21 AM, John M. Dlugosz
<l3hc4oo02@sneakemail.com> wrote:[color=blue]
> OK, when I defined $r as you did, it worked. For documentation, I was
> looking at here:
> <http://search.cpan.org/~joesuf/libapreq2-2.08/glue/perl/lib/Apache2/Request.pm>[/color]
Hi John,
That SYNOPSIS is more like a set of possible calls to
Apache2::Request, not a literal series of lines. You do need to get
$r (an Apache2::RequestRec object) first.
[color=blue]
> I see you are just printing to standard output, like a CGI script.[/color]
When using ModPerl::Registry, you can just print to STDOUT.
[color=blue]
> In the book, it used
>
> $r->send_http_header('text/plain');
> $r->print("mod_perl rules!\n");
>
> but there are no such methods on $r here in 2.0.
>
> What, prey tell, is the equivalent object?[/color]
That's Apache2::RequestRec.
[color=blue]
> Is there =any= way to get started, like a simple (but working!) program I
> could look at?[/color]
There are two places you should look for MP2 docs. The first is the
mod_perl site, which has all the API docs and many examples. If you
want a book, the only one you should use for MP2 at this point is
"mod_perl2 User's Guide": [url]http://modperl2book.org/[/url]
- Perrin