Hi,
Am Sonntag, 18. Januar 2004 01:32 schrieb Stas Bekman:
Boris Zentner wrote:
Hi,
Am Donnerstag, 15. Januar 2004 01:41 schrieb Stas Bekman:
Please take a look at this new manpage http://perl.apache.org/docs/2.0/api/Apache.html
This issue of ghost Apache namespace troubles me. In mod_perl 1.0 it was OK to have functions like Apache::current_callback() because almost everything was preloaded. I don't think it's OK in mp2. It's absolutely not obvious which module needs to be loaded to get this API, and most people will try to load Apache, and it won't do the trick.
This is very confusing and incomprehencible to me. My last mp2 application starts with:
use mod_perl 1.99; use Apache::RequestRec (); use Apache::RequestIO (); use Apache::ServerUtil (); use Apache::RequestUtil (); use Apache::Util (); use APR::Date (); use APR::Table();
and im sure my next project start with this lines too. If someone ask why my answer is I do not know, but it does not work otherwise.
And that's fine. Think of mp2 as a bunch of CPAN modules. You need to load them before you can use them.
That is fine and reasonable to me. My point is that once I have an object I want to be sure that I can use every method for this object. For example this implies that whenever I have a RequestRec object that can print, I must be sure that I can do so without loading Apache::RequestIO.
It is ok to 'use APR::Date' if I like to use a function of it or operate on a object that I can produce. But it is not ok in my opinion that my Apache::RequestRec object gets magical date methods.
But none of Apache::Request* classes is a subclass of each other. There is no inheritance tree. All they do is nicely spread the methods across several modules, giving you better fine tuning. So when you get $r in your handler we have no idea what methods you are going to need, and which classes you need to load. It's quite possible that you never going to use Apache::RequestRec, so any guessing is wrong.
I think the best solution for your kind of pain is the one that Josh has proposed:
use Apache::whatever qw(:request);
and you get all Apache::Request* modules loaded and now you have all the mp2 methods that you can operate on $r.
use Apache::whatever qw(:request :server);
and you get Apache::Request* and Apache::Server* loaded. That is very similar to how CGI.pm imports its function interface symbols via tags, though here we deal with modules.
__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
