Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Apache conflicts with my modules

by IOrdy (Friar)
on Aug 29, 2001 at 17:24 UTC ( [id://108748]=note: print w/replies, xml ) Need Help??


in reply to Re: Apache conflicts with my modules
in thread Apache conflicts with my modules

you can check the code for my module under this node. Apart from some small changes (dumb stuff like returning my $class instead of $self) it's pretty much the same.

The script I'm calling it from is stripped back to:
#!/usr/bin/perl -w use lib '/home/iordy/perl.iordy.net'; use strict; use iXML::TheConstruct; use Apache::Request; my $r = Apache->request; my $apr = Apache::Request->new($r); my $construct = iXML::TheConstruct->new();

regardless of where I have 'my $r = Apache->request;' it tells me It cannot find the method "new()" under module Apache::Request;.

now I have written stuff (1 or 2 things only; I'm new to perl) in this manner before but I have never done it with a module I have written myself (the module shown in the node listed above is my first ever attempt.)

so I'm stumped as to why this would be happening.

Replies are listed 'Best First'.
Re: Re: Re: Apache conflicts with my modules
by echo (Pilgrim) on Aug 29, 2001 at 17:52 UTC
    Is libapreq installed? That's where the Apache::Request object comes from. If you don't need its extended features, you can just use $r which is usually enough.

    BTW, you can write:

    my $r = shift;
    instead of
    my $r = Apache->request;
      I was told I should be using Apache::Request for things like:
      my $r = Apache->request; my $apr = Apache::Request->instance($r, DISABLE_UPLOADS => 1); my $args = $apache_request->param;
      Someone (I think it was on here) said it was better/safer than using just $r as I could set stuff like DISABLE_UPLOADS and the max size for post/get requests.

      What is it with shift? To tell you the truth I dont understand how it can be use in such an instance. I know that it returns & removes the first argument in an array ie. @ARGV , @_ or @whatever. I know that Apache wraps your script so that having it in my script (not a sub) should return the class name i.e Apache but why can it replace Apache->request which I thought would be a subroutine?
        Hi again! Your reasons for using Apache::Request are valid. I just wanted to make sure you had a purpose...

        About my $r = shift;: when you use Apache::Registry or Apache::PerlRun to run a script under mod_perl, it is wrapped in a sub, and the first argument provided is the request object. Is is just a convenient shortcut provided by mod_perl. The request object is created by mod_perl when the request comes in, long before your script is actually called. There is only one instance of the request object for the whole lifetime of the request.

        To further debug your Apache::Request problem, I suggest commenting it out and see if your script runs fine without it. This would help to isolate the cause of the error.

        Change:

        $apr = Apache::Request->new($r, DISABLE_UPLOADS => 1); my $args = $apache_request->param;
        to
        my %args = $r->method eq 'GET' ? $r->args : $r->content;
        and see what happens.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-23 19:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found