Re: Migrating from CGI.pm to Apache::Request question.

2002-11-21 Thread Stas Bekman
Jesse Erlbaum wrote:

Hi Coexec --



I am experienced with using the CGI.pm, and now I want
to rewrite all of my CGI's using mod_perl and
Apache::Request.




Maybe a silly question:  What are you hoping to gain by doing this?


Speed. Apache::Request's guts are implemented in C, CGI.pm is Perl. If 
you do a lot of processing the speed improvement is significant. See:
http://perl.apache.org/docs/1.0/guide/performance.html#Apache__args_vs__Apache__Request__param_vs__CGI__param

_
Stas Bekman JAm_pH  --   Just Another mod_perl Hacker
http://stason.org/  mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/




Re: Migrating from CGI.pm to Apache::Request question.

2002-11-19 Thread Ken Y. Clark
On Tue, 19 Nov 2002, Coexec wrote:

 Date: Tue, 19 Nov 2002 15:40:37 -0800 (PST)
 From: Coexec [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Migrating from CGI.pm to Apache::Request question.
 
 Hello all, I have been searching through the mailing
 list archives for the answer to my question, but I
 have not found it.
 
 I am experienced with using the CGI.pm, and now I want
 to rewrite all of my CGI's using mod_perl and
 Apache::Request.  According to everything that I have
 been reading, the Apache::Request module handles only
 GET, POST and Cookie data, and no HTML.  Basically, my
 question is, what is the most commonly used module for
 generating HTML like the CGI.pm does ?
 
 Thanks

There are so many different ways to handle HTML generation that it
will make your head spin.  You're always welcome to continue using
CGI.pm's methods for generating HTML, but that usually couples the
logic and presentation of your application so tightly that it makes
for less-than-maintainable code -- less than what, however, remains
the question.  Many people like to use templating systems
(HTML::Template, Template::Toolkit), some like to use more
all-inclusive packages (Mason, Apache::ASP, Embperl), some people just
use print statements (arguably the worst choice).  Asking what is
the most common way people on this list won't likely generate a
consensus;  ask 10 people how they do this and you'll probably get 10
different answers.  

As for me, I'm quite partial to Template::Toolkit.  You'll have to
decide what works best for you.  No need to use a sledgehammer to
drive a finishing nail.  Use whatever tool is the simplest to use for
your situation, but no simpler.  :-)

ky




RE: Migrating from CGI.pm to Apache::Request question.

2002-11-19 Thread Jesse Erlbaum
Hi Coexec --

 I am experienced with using the CGI.pm, and now I want
 to rewrite all of my CGI's using mod_perl and
 Apache::Request.


Maybe a silly question:  What are you hoping to gain by doing this?


If you're already using Apache::Registry, then your CGI.pm apps are ALREADY
running as mod_perl modules.  The move from CGI.pm to Apache::Request, in
this case, is not likely to give you any real speed advantage.

As you've pointed out, Apache::Request is only a partial replacement for
CGI.pm.  Ken suggested that you could continue to use CGI.pm in addition to
Apache::Request if you need the functionality.  If you choose to do so you
will be using even MORE code than CGI.pm alone.  More code means more
memory, at very least -- not to mention the complexity of the system.

Finally, you have to throw away all that time you spent learning the finer
points of CGI.pm, and spend time learning the finer points of
Apache::Request.  Multiply that by the number of developers you have.

I see that a few people have been doing this over the years, but I still
don't see the advantage.  Other than the Siren call of don't use CGI.pm --
it's evil, I can't imagine that Apache::Request has any really compelling
advantages.

Personally, I use CGI.pm (via CGI::Application) for my applications and
straight mod_perl handlers for low-level functionality such as
authentication, authorization and custom logging.  This allows the majority
of my developers, who are engaged in writing application code (the vast
majority of the work on the typical project), to leverage their expertise.
More advanced mod_perl hacks work on the heavy lifting handlers, which are
few and far between.


On a related topic, I strongly agree with Ken that you should move your HTML
generation into a templating system.  HTML::Template is my personal
preference.  I use H::T in conjunction with CGI::Application to implement
all my web apps.  FWIW, CGI::Application works equally well with Template
Toolkit, if that's your preference.


Warmest regards,

-Jesse-


--

  Jesse Erlbaum
  The Erlbaum Group
  [EMAIL PROTECTED]
  Phone: 212-684-6161
  Fax: 212-684-6226