You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Drew Taylor <dt...@vialogix.com> on 2000/04/03 22:57:07 UTC
Transitioning from Apache::Registry
Hello all,
In light of the recent "performance monger" thread, I am interested in
information about transitioning from Registry scripts to Apache
handlers. Here is my situation, which I'm guessing is pretty common.
I have a series of scripts (search.pl for instance) which determines the
action to perform based on QUERY_STRING/POST params. It then calls the
appropriate method in an OO Perl Module, which does it's stuff and
prints the page using HTML::Template. So a typical request looks like
"/cgi-bin/search.pl?A=R&blah=1&foo=2". The initial script does something
like this:
use Search;
use CGI;
my $q = new CGI;
my $action = $q->param('A');
my $object = Search->($CGI);
if ($action eq 'R') {
$object->searchResults;
} elsif ($action eq 'S') {
$object->Search;
}
I understand the speed/memory benefits of not setting up CGI
environment, but how do I go about making the transition? I have a (I
hope) good understanding of writing a pure Apache module, but am unsure
of how to transfer the functionality. Should I just use Apache::Request
instead of CGI.pm? (I do use the cookie & checkbox/pulldown
functionality often). If there are any tutorials out there, I'd love
some links. I love to document my journey for the benefit of others as
well.
Here's hoping for some good pointers/hints. :-)
--
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704.370.0550
http://www.vialogix.com
Re: Transitioning from Apache::Registry
Posted by Drew Taylor <dt...@vialogix.com>.
Ahh yes, the <Perl> Sections... I've read briefly about them, but have
not used it yet. Looks like I'll be learning it soon. I have many sites
coming online in the near future that will have nearly identical setups
like this one.
Thanks Stas.
Stas Bekman wrote:
>
> > On Mon, 3 Apr 2000, Drew Taylor wrote:
> > > And I would need to setup a <Location> directive for each function
> > > (Search, Cart, etc)?
> >
> > You probably want to set up one for each Apache::Registry script you have
> > right now, unless you don't like the way they're structured and want to
> > re-work it.
>
> Look into <Perl> sections to generate all the required configurations to
> save you redundant typing and errors.
>
> See http://perl.apache.org/guide/config.html#_Perl_Perl_Sections
--
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704.370.0550
http://www.vialogix.com
Re: Transitioning from Apache::Registry
Posted by Stas Bekman <sb...@stason.org>.
> On Mon, 3 Apr 2000, Drew Taylor wrote:
> > So I just write a small handler which does the same thing as the .pl
> > script and add a <Location /cgi-bin/search.pl> directive to use this
> > handler?
>
> Yes, that should work fine.
>
> > And I would need to setup a <Location> directive for each function
> > (Search, Cart, etc)?
>
> You probably want to set up one for each Apache::Registry script you have
> right now, unless you don't like the way they're structured and want to
> re-work it.
Look into <Perl> sections to generate all the required configurations to
save you redundant typing and errors.
See http://perl.apache.org/guide/config.html#_Perl_Perl_Sections
______________________________________________________________________
Stas Bekman | JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ | mod_perl Guide http://perl.apache.org/guide/
mailto:stas@stason.org | http://perl.org http://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
----------------------------------------------------------------------
Re: Transitioning from Apache::Registry
Posted by Perrin Harkins <pe...@primenet.com>.
On Mon, 3 Apr 2000, Drew Taylor wrote:
> So I just write a small handler which does the same thing as the .pl
> script and add a <Location /cgi-bin/search.pl> directive to use this
> handler?
Yes, that should work fine.
> And I would need to setup a <Location> directive for each function
> (Search, Cart, etc)?
You probably want to set up one for each Apache::Registry script you have
right now, unless you don't like the way they're structured and want to
re-work it.
- Perrin
Re: Transitioning from Apache::Registry
Posted by Drew Taylor <dt...@vialogix.com>.
Perrin Harkins wrote:
>
> That should be pretty easy to convert, since you already have your main
> program logic off in a separate module.
So I just write a small handler which does the same thing as the .pl
script and add a <Location /cgi-bin/search.pl> directive to use this
handler? That sounds very easy. :-) And I would need to setup a
<Location> directive for each function (Search, Cart, etc)?
> Use Apache::Request and Apache::Cookie (both in the libapreq
> distribution). I don't use the sticky forms stuff in CGI.pm, so I don't
> know if there's a handy replacement. Check CPAN or just roll your own.
> Maybe you could make a subclass of Apache::Request that adds somemethods
> for this.
I'll look into the forms stuff. I'm sure there is some equivalent in
Apache::xxx modules. Thanks for the info. I've been writing perl for a
couple years now, but the complete mod_perl experience is still new to
me.
--
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704.370.0550
http://www.vialogix.com
Re: Transitioning from Apache::Registry
Posted by Perrin Harkins <pe...@primenet.com>.
On Mon, 3 Apr 2000, Drew Taylor wrote:
> In light of the recent "performance monger" thread, I am interested in
> information about transitioning from Registry scripts to Apache
> handlers. Here is my situation, which I'm guessing is pretty common.
[...]
> use Search;
> use CGI;
> my $q = new CGI;
> my $action = $q->param('A');
> my $object = Search->($CGI);
> if ($action eq 'R') {
> $object->searchResults;
> } elsif ($action eq 'S') {
> $object->Search;
> }
That should be pretty easy to convert, since you already have your main
program logic off in a separate module.
> Should I just use Apache::Request instead of CGI.pm? (I do use the
> cookie & checkbox/pulldown functionality often).
Use Apache::Request and Apache::Cookie (both in the libapreq
distribution). I don't use the sticky forms stuff in CGI.pm, so I don't
know if there's a handy replacement. Check CPAN or just roll your own.
Maybe you could make a subclass of Apache::Request that adds somemethods
for this.
> If there are any tutorials out there, I'd love some links.
It really isn't difficult enough to merit a tutorial, in my opinion. It's
just ordinary perl module stuff.
- Perrin