[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: Trouble with mod_perl API: E.g., Apache2::Directive::conftree()
From:       John Dunlap <john () lariat ! co>
Date:       2014-05-15 13:56:11
Message-ID: CAC5eUSvx-kGx4u=JihfntmgNBkU+GSU=uggOeeiPKv6dPyak8Q () mail ! gmail ! com
[Download RAW message or body]

Why can't you just do this?

sub handler {
    my ($apache) = @_;
    my $documentroot = $apache->document_root;
}




On Tue, May 13, 2014 at 8:24 PM, Worik Stanton <worik.stanton@gmail.com>wrote:

> I am having a lot of trouble with mod_perl APIs.
>
> The short of it is that when I say:
>
> use Apache2::Directive ();
> my $tree = Apache2::Directive::conftree();
> my $documentroot = $tree->lookup('DocumentRoot');
> warn "\$documentroot '$documentroot'";
>
> I get:
> [Wed May 14 12:13:43 2014] -e: Use of uninitialized value $documentroot
> in concatenation (.) or string at /home/worik/Worik.org/cgi/track line 11.
> [Wed May 14 12:13:43 2014] -e: $documentroot '' at
> /home/worik/Worik.org/cgi/track line 11.
>
> in the logs.
>
> I copied the code from
> https://perl.apache.org/docs/2.0/api/Apache2/Directive.html
>
> The longer of it is:
>
> In the past (15 years ago) I installed mod_perl and forgot about it. I
> set up my perl cgi script handler to be mod_perl in httpd.conf, and the
> only real effect it had on my development cycle was I often had to
> restart Apache to get it to notice I had changed a script.
>
> These days I am more ambitious and am returning to Web programming after
> a long break.
>
> I expect mod_perl to still be useful to cut the overhead of starting
> Perl. I expect a high throughput this time around, each request will be
> worth very little to me so I want lots and lots of requests.  SO far so
> good.
>
> I have set up my server:
>
>         ## mod_perl2 configuration
>         Alias /cgi/  /home/worik/Worik.org/cgi/
>         PerlModule ModPerl::Registry
>         ## PerlModule Apache::Registry
>         PerlSwitches -T
>         ErrorLog ${APACHE_LOG_DIR}/Worik.error.log
>         <Location /cgi/>
>            SetHandler perl-script
>            PerlResponseHandler ModPerl::Registry
>            PerlOptions +ParseHeaders
>            Options +ExecCGI
>            Order allow,deny
>            Allow from all
>         </Location>
>
> Now I would like to use the API.  In the first instance I want to find
> what the directory is I am running in.  So I want to say:
>
> use Apache2::Directive ();
> my $tree = Apache2::Directive::conftree();
> my $pwd = $tree->lookup("cgi");
>
> But that fails just like the example at the start of this email.
>
> Also my errors are coming out in the wrong log.  When I say warn("foo")
> I expect it to come out in the file specified by the ErrorLog directive
> but it comes as:
>
> [Wed May 14 12:22:53 2014] -e: foo at /home/worik/Worik.org/cgi/track
> line 12.
>
> in /var/log/apache2/error.log which is not what I specified.
>
> I am at a loss.  Is the documentation up to date?  Is mod_perl still
> being used out there?
>
> cheers
> Worik
>
> --
> The only true evil is turning people into things....
>                                          Granny Weatherwax
>        worik.stanton@gmail.com 021-1680650, (03) 4821804
>                           Aotearoa (New Zealand)
>
>
>

[Attachment #3 (text/html)]

<div dir="ltr">Why can&#39;t you just do this?<div><br></div><div><div>sub handler \
{</div><div>      my ($apache) = @_;</div><div><span \
style="font-size:13px;font-family:arial,sans-serif">      my $documentroot =</span>  \
$apache-&gt;document_root;<br> \
</div></div><div>}</div><div><br></div><div><br></div></div><div \
class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 13, 2014 at 8:24 PM, \
Worik Stanton <span dir="ltr">&lt;<a href="mailto:worik.stanton@gmail.com" \
target="_blank">worik.stanton@gmail.com</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">I am having a lot of trouble with mod_perl APIs.<br> <br>
The short of it is that when I say:<br>
<br>
use Apache2::Directive ();<br>
my $tree = Apache2::Directive::conftree();<br>
my $documentroot = $tree-&gt;lookup(&#39;DocumentRoot&#39;);<br>
warn &quot;\$documentroot &#39;$documentroot&#39;&quot;;<br>
<br>
I get:<br>
[Wed May 14 12:13:43 2014] -e: Use of uninitialized value $documentroot<br>
in concatenation (.) or string at /home/worik/Worik.org/cgi/track line 11.<br>
[Wed May 14 12:13:43 2014] -e: $documentroot &#39;&#39; at<br>
/home/worik/Worik.org/cgi/track line 11.<br>
<br>
in the logs.<br>
<br>
I copied the code from<br>
<a href="https://perl.apache.org/docs/2.0/api/Apache2/Directive.html" \
target="_blank">https://perl.apache.org/docs/2.0/api/Apache2/Directive.html</a><br> \
<br> The longer of it is:<br>
<br>
In the past (15 years ago) I installed mod_perl and forgot about it. I<br>
set up my perl cgi script handler to be mod_perl in httpd.conf, and the<br>
only real effect it had on my development cycle was I often had to<br>
restart Apache to get it to notice I had changed a script.<br>
<br>
These days I am more ambitious and am returning to Web programming after<br>
a long break.<br>
<br>
I expect mod_perl to still be useful to cut the overhead of starting<br>
Perl. I expect a high throughput this time around, each request will be<br>
worth very little to me so I want lots and lots of requests.   SO far so<br>
good.<br>
<br>
I have set up my server:<br>
<br>
            ## mod_perl2 configuration<br>
            Alias /cgi/   /home/worik/Worik.org/cgi/<br>
            PerlModule ModPerl::Registry<br>
            ## PerlModule Apache::Registry<br>
            PerlSwitches -T<br>
            ErrorLog ${APACHE_LOG_DIR}/Worik.error.log<br>
            &lt;Location /cgi/&gt;<br>
                 SetHandler perl-script<br>
                 PerlResponseHandler ModPerl::Registry<br>
                 PerlOptions +ParseHeaders<br>
                 Options +ExecCGI<br>
                 Order allow,deny<br>
                 Allow from all<br>
            &lt;/Location&gt;<br>
<br>
Now I would like to use the API.   In the first instance I want to find<br>
what the directory is I am running in.   So I want to say:<br>
<br>
use Apache2::Directive ();<br>
my $tree = Apache2::Directive::conftree();<br>
my $pwd = $tree-&gt;lookup(&quot;cgi&quot;);<br>
<br>
But that fails just like the example at the start of this email.<br>
<br>
Also my errors are coming out in the wrong log.   When I say \
warn(&quot;foo&quot;)<br> I expect it to come out in the file specified by the \
ErrorLog directive<br> but it comes as:<br>
<br>
[Wed May 14 12:22:53 2014] -e: foo at /home/worik/Worik.org/cgi/track<br>
line 12.<br>
<br>
in /var/log/apache2/error.log which is not what I specified.<br>
<br>
I am at a loss.   Is the documentation up to date?   Is mod_perl still<br>
being used out there?<br>
<br>
cheers<br>
<span class="HOEnZb"><font color="#888888">Worik<br>
<br>
--<br>
The only true evil is turning people into things....<br>
                                                              Granny Weatherwax<br>
           <a href="mailto:worik.stanton@gmail.com">worik.stanton@gmail.com</a> \
021-1680650, (03) 4821804<br>  Aotearoa (New Zealand)<br>
<br>
<br>
</font></span></blockquote></div><br></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic