On 9/16/05, Frank Carnovale
<[EMAIL PROTECTED]> wrote:
> Guys,
> 
> Here's my take on why that "naughty" code is there.
> In short:
> 
> It is because prior to the first request, no "handler" routine is there yet, 
> and when the first request is handled, it's not passed as an OO-style call 
> but as a plain old subroutine call, so no inheritance technique was going to 
> find a "handler" out of somewhere else.

You're right, but the non-existence of the handler() method/function
is a separate issue - see below.

> 
> Example:
> 
> One of our Maypole apps is ITSRR::Prism.
> 
> <Location /prism >
>     SetHandler perl-script
>     PerlResponseHandler ITSRR::Prism
> </Location>
> 
> Life-cycle of first ever request:
> 
> In a just-in-time fashion, ModPerl finds that ITSRR::Prism is not already in 
> its namespace so it gets automatically 'required' prior handling the first 
> request.

In mod_perl 1, if you said PerlHandler +ITSRR::Prism, the code would be loaded 
in the parent during startup, saving you a big chunk of memory. Or you
could use ITSRR::Prism in a startup.pl script to get it loaded in the
parent.

> During the require, the module-level code calls Maypole::setup (via its 
> inheritance chain) which as we know uses the "naughty" technique to add a 
> handler entry into the ITSRR::Prism namespace.
> Once the require is finished, modperl is finally ready to get this pending 
> first-ever request dealt with.  It calls something like this: 
> ITSRR::Prism::handler($r) where the $r is an Apache::Request object (note not 
> a Maypole request!).  That call is not an OO-style call.. it's just a call to 
> a sub out of that package.  Therefore no rules about following inheritance 
> chains to find the method "handler" are going to be applied.  So if the 
> naughty bit is not done, no handler is available to service the request.
> 
> If modperl had invoked ITSRR::Prism->handler($r) .. note the arrow technique 
> in other words a "method" call..  then I suppose the naughty technique would 
> be unnecessary.  I note that modperl does support exactly this if you want, 
> see http://perl.apache.org/docs/2.0/user/coding/coding.html#Method_Handlers . 
>  But I get the impression from the modperl 1&2 docs that this is unchartered 
> waters (by me anyway), and requires a special build of modperl.

It's compiled in by default AFAIK. You just need to prototype the
handler method to switch it on. So if Maypole::handler was prototyped
as ($$), mod_perl would call it as a method and we wouldn't need the
naughtiness.

However, I suspect this would break Maypole under CGI, because there
is no parameter in the handler call. The prototype would need to be
($;$). And I'm guessing that prototype would *not* invoke mod_perl's
method handler behaviour, and we're back to needing something naughty.

Ah well, a little bit of naughtiness never hurt anybody. 

d.


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Maypole-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-devel

Reply via email to