You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Clinton Gormley <cl...@drtech.co.uk> on 2002/11/01 10:28:02 UTC

Should I be coding with mod_perl 2 yet?

I'm struggling to get anything much working with mod_perl 2.

I have installed mod_perl 1.99_07 with Apache 2.0.43. I have read all of
the documentation on perl.apache.org.

I can get a basic page returned to me with a modperl handler, but as
soon as I try to do anything of note (eg Apache->push_handlers() (or
should that be Apache2->push_handlers()? - neither works), get query
string parameters, etc) I run into a brick wall.

I'm starting on a new project which I'd like to launch (phase 1) in the
next 3 months - am I being too ambitious in trying to use modperl 2
already? Is it just too damn early?

If these things should be working, where can I find out how to use them?
I've scoured the source files without much success (most modules are XS
wrappers - and my C is non-existent).

Thoughts?

thanks

Clint



Re: Should I be coding with mod_perl 2 yet?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Clinton Gormley wrote:
> I'm struggling to get anything much working with mod_perl 2.
> 
> I have installed mod_perl 1.99_07 with Apache 2.0.43. I have read all of
> the documentation on perl.apache.org.
> 
> I can get a basic page returned to me with a modperl handler, but as
> soon as I try to do anything of note (eg Apache->push_handlers() (or
> should that be Apache2->push_handlers()? - neither works), get query
> string parameters, etc) I run into a brick wall.
> 

I've only started to dabble with mod_perl 2, but I didn't find it too 
difficult.  the real drawback was that whereas mod_perl 1.0 use()d 
most of the classes for you behind the scenes (like Apache::Table), 
with mod_perl 2.0 you need to use() them yourself, which means you 
have to figure out which classes provide which methods.

my only work to date can be found here:

http://www.modperlcookbook.org/~geoff/modules/experimental/Apache-Clean-2.00b.tar.gz

Apache::Clean is a PerlOutputFilterHandler, but the tests include two 
simple PerlResponseHandlers, and it's pretty well commented, so it 
should serve as a starting point for which classes you're likely to 
need.  I found all the classes I needed by grep'ing the t/ directory 
in the mod_perl distribution for the methods in question, adding them 
one by one, then, when it worked, checking the source for the module 
in question to learn what was going on...

--Geoff




Re: Should I be coding with mod_perl 2 yet?

Posted by Sumitro Chowdhury <su...@yahoo.com>.
--- Randy Kobes <ra...@theoryx5.uwinnipeg.ca> wrote:
> 
>     my %args = $r->Apache::args;
> is for GET requests. For POST, as is described in
> the 
> content() method of Apache::compat, for now one can
> use
> 
>   $r->setup_client_block;
>   # return an error unless $r->should_client_block;
>   my $len = $r->headers_in->get('content-length');
>   my $buf;
>   $r->get_client_block($buf, $len);
>   my %args = map {
>        s/%([0-9a-fA-F]{2})/pack("c", hex($1))/ge;
>        $_;
>   } split /[=&;]/, $buf, -1;

Just to help real newbies like me , we can also add
"+" substitution so that the above line becomes:
    my %args = map {
         s/%([0-9a-fA-F]{2})/pack("c", hex($1))/ge;
         s/\+/ /g; 
         $_;
    } split /[=&;]/, $buf, -1;

Thanks a lot, Randy.
Regards,
Sumitro Chowdhury.
     
> 
> Some of the issues regarding, in particular, using
> the 
> mod_perl-1-ish $r->args and $r->content in an array
> context
> are discussed at
>  
>
http://perl.apache.org/docs/2.0/user/compat/compat.html
> But you do have a point that life will be easier
> when libapreq 
> is ready :)
>  
> -- 
> best regards,
> randy
> 


__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/

Re: Should I be coding with mod_perl 2 yet?

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Fri, 1 Nov 2002, Sumitro Chowdhury wrote:

> Hmmmm....
> I thought POST request handling needs
> $r->read($buf,$r->headers_in->{'Content-length'})
> and GET request handling needs
> $r->args();

Sorry about that - I should have read more carefully that
you were specifically referring to POSTed data - 
    my %args = $r->Apache::args;
is for GET requests. For POST, as is described in the 
content() method of Apache::compat, for now one can use

  $r->setup_client_block;
  # return an error unless $r->should_client_block;
  my $len = $r->headers_in->get('content-length');
  my $buf;
  $r->get_client_block($buf, $len);
  my %args = map {
       s/%([0-9a-fA-F]{2})/pack("c", hex($1))/ge;
       $_;
  } split /[=&;]/, $buf, -1;

Some of the issues regarding, in particular, using the 
mod_perl-1-ish $r->args and $r->content in an array context
are discussed at
  http://perl.apache.org/docs/2.0/user/compat/compat.html
But you do have a point that life will be easier when libapreq 
is ready :)
 
-- 
best regards,
randy


Re: Should I be coding with mod_perl 2 yet?

Posted by Sumitro Chowdhury <su...@yahoo.com>.
--- Randy Kobes <ra...@theoryx5.uwinnipeg.ca> wrote:
> On Fri, 1 Nov 2002, Sumitro Chowdhury wrote:
> 
> > Hi,
> > well I have read all (whatever scanty little
> > available) docs on mod_perl 2 and am pretty
> > disappointed.
> 
> Additions, I'm sure, are welcome :)
> 
> > For example Apache::Request is not ready yet so
> you
> > need Apache::compat and mod_perl 1 for basic POST
> > request handling and parsing.
> > 
> > In my opinion, stay with mod_perl 1.
> 
> They're working on libapreq for Apache2, and as has
> been
> pointed out, mod_perl-2 is still in the development
> stage. For basic form handling, though, you can use
>     my %args = $r->Apache::args;

Hmmmm....
I thought POST request handling needs
$r->read($buf,$r->headers_in->{'Content-length'})
and GET request handling needs
$r->args();

Thank you, Randy for the quick response. Since I have
watched your contribution to the list, I was hoping if
you could discuss {setup,should,get}_client_block API
for handling POST data on this list.

Inspite of all my rantings, I still use mod_perl 2.0
;-)

Thanks again,
Sumitro Chowdhury

> 
> -- 
> best regards,
> randy kobes
> 


__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/

Re: Should I be coding with mod_perl 2 yet?

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Fri, 1 Nov 2002, Sumitro Chowdhury wrote:

> Hi,
> well I have read all (whatever scanty little
> available) docs on mod_perl 2 and am pretty
> disappointed.

Additions, I'm sure, are welcome :)

> For example Apache::Request is not ready yet so you
> need Apache::compat and mod_perl 1 for basic POST
> request handling and parsing.
> 
> In my opinion, stay with mod_perl 1.

They're working on libapreq for Apache2, and as has been
pointed out, mod_perl-2 is still in the development
stage. For basic form handling, though, you can use
    my %args = $r->Apache::args;

-- 
best regards,
randy kobes


Re: Should I be coding with mod_perl 2 yet?

Posted by Sumitro Chowdhury <su...@yahoo.com>.
Hi,
well I have read all (whatever scanty little
available) docs on mod_perl 2 and am pretty
disappointed.

For example Apache::Request is not ready yet so you
need Apache::compat and mod_perl 1 for basic POST
request handling and parsing.

In my opinion, stay with mod_perl 1.

-Sumitro Chowdhury.

--- Ged Haywood <ge...@www2.jubileegroup.co.uk> wrote:
> Hi there,
> 
> On 1 Nov 2002, Clinton Gormley wrote:
> 
> > I'm struggling to get anything much working with
> mod_perl 2.
> [snip]
> > I have read all of the documentation on
> perl.apache.org.
> 
> Are you sure?  :)
> 
> > If these things should be working,
> 
> Well it does say on the home page that it's the
> "Bleeding Edge".
> 
> > where can I find out how to use them?
> 
> Here.  mod_perl for Apache 2.x is still at the
> development stage, but
> people are using it.  You can more specific help if
> you ask a more
> specific question (but you won't get it from me, I
> haven't even looked
> at Apache 2.x yet:).
> 
> 73,
> Ged.
> 
> 
> 
> 
> 


__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/

Re: Should I be coding with mod_perl 2 yet?

Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
Hi there,

On 1 Nov 2002, Clinton Gormley wrote:

> I'm struggling to get anything much working with mod_perl 2.
[snip]
> I have read all of the documentation on perl.apache.org.

Are you sure?  :)

> If these things should be working,

Well it does say on the home page that it's the "Bleeding Edge".

> where can I find out how to use them?

Here.  mod_perl for Apache 2.x is still at the development stage, but
people are using it.  You can more specific help if you ask a more
specific question (but you won't get it from me, I haven't even looked
at Apache 2.x yet:).

73,
Ged.