Why load two modules to call methods on the same object?

This is a discussion on Why load two modules to call methods on the same object? within the Apache forums in Application Servers & Tools category; For the following to work I must load Apache2RequestRec as well as Apache2::RequestIO. package GS; use Apache2::Const -compile => ':common'; use Apache2::RequestRec ();# $r->content_type use Apache2::RequestIO (); # $r->print sub handler { my $r = shift; print $r->content_type('text/plain'); print $r->print("hello, world"); return Apache2::Const::OK; } 1; There must be a reason we have it this way. Any clues? Thanks, Himanshu...

Go Back   Application Development Forum > Application Servers & Tools > Apache

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-16-2008, 11:00 PM
Himanshu
Guest
 
Default Why load two modules to call methods on the same object?

For the following to work I must load Apache2RequestRec as well as
Apache2::RequestIO.

package GS;
use Apache2::Const -compile => ':common';
use Apache2::RequestRec ();# $r->content_type
use Apache2::RequestIO (); # $r->print

sub handler {
my $r = shift;
print $r->content_type('text/plain');
print $r->print("hello, world");
return Apache2::Const::OK;
}

1;

There must be a reason we have it this way. Any clues?

Thanks,
Himanshu

Reply With Quote
  #2  
Old 09-17-2008, 01:32 AM
John Drago
Guest
 
Default Re: Why load two modules to call methods on the same object?




--- On Tue, 9/16/08, Himanshu <himanshu.garg@gmail.com> wrote:

> From: Himanshu <himanshu.garg@gmail.com>
> Subject: Why load two modules to call methods on the same object?
> To: modperl@perl.apache.org
> Date: Tuesday, September 16, 2008, 9:00 PM
> For the following to work I must load Apache2RequestRec as
> well as
> Apache2::RequestIO.
>
> package GS;
> use Apache2::Const -compile => ':common';
> use Apache2::RequestRec ();# $r->content_type
> use Apache2::RequestIO (); # $r->print
>
> sub handler {
> my $r = shift;
> print $r->content_type('text/plain');
> print $r->print("hello, world");
> return Apache2::Const::OK;
> }
>
> 1;
>
> There must be a reason we have it this way. Any clues?
>
> Thanks,
> Himanshu



<rant>
I've been coding with mod_perl since 2000 (IIRC) and I don't have a straightforward answer for you.

I suppose it's possible that rather than load up all the "non-core" behaviors (like, you know, really strange ones that nobody ever uses, like "print") you have to load those modules yourself.

Just keep repeating to yourself, "This is to make mod_perl faster."
</rant>

One advantage you get by having to load up those modules yourself is that you can (in theory) shave off an extra millisecond or two. Somehow magickally.

I wish mod_perl handlers were a bit more intuitive myself. The whole thing just seems very un-Perlish. Probably because it's just a very thin layer around the Apache API.

Go figure.












Reply With Quote
  #3  
Old 09-17-2008, 08:57 AM
Perrin Harkins
Guest
 
Default Re: Why load two modules to call methods on the same object?

On Tue, Sep 16, 2008 at 11:00 PM, Himanshu <himanshu.garg@gmail.com> wrote:
> For the following to work I must load Apache2RequestRec as well as
> Apache2::RequestIO.


The idea is that you don't load what you don't need, which reduces
memory consumption, which is the bottleneck on most mod_perl
applications. I think it's usually not worth it, but that was the
theory.

- Perrin

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:58 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.