Re: Getting ugly: mod_perl and traditional forms of writing CGI

2002-08-08 Thread Andrew Ho

Hello,

SS>The below is a sample bit of code I am using for very simple forum
SS>software. It acts erratically, sometimes seeing the contents of the form
SS>being POSTed to it and sometimes not. If a form POSTed is under 500
SS>bytes in length it works fine. Anything higher is hit and miss.
SS>
SS>community.cgi:
SS>--
SS>package Kittens::Community;

You don't want to use an explicit package statement in an Apache::Registry
script because Apache::Registry creates its own package name for the
current script. I can't find a on-line reference for this right now, but I
recall it causing sporadic problems.

SS>I'm thinking that the step of going from writing simple Perl CGI scripts
SS>to mod_perl is one that many people will be going through and a
SS>documenting a lot of this (basic mod_perl writing techniques) online
SS>would be incredibly helpful. So you're not just helping me, you're
SS>helping an entire future community of mod_perl developers.

You should really take some time to look through the excellent mod_perl
Guide, which is exactly this, a bunch of knowledge compiled together in a
tutorial type way. You can read the Guide on-line here:

http://perl.apache.org/docs/1.0/guide/

In fact, there is a section specifically discussing converting CGI scripts
to run under mod_perl.


http://perl.apache.org/docs/1.0/guide/getwet.html#Porting_Existing_CGI_Scripts_to_run_under_mod_perl

In general, you will get much better error reporting and if you are
running with warnings and "use strict" in all of your scripts. You can
find out how to enable these in the Guide.

Humbly,

Andrew

--
Andrew Ho   http://www.tellme.com/   [EMAIL PROTECTED]
Engineer   [EMAIL PROTECTED]  Voice 650-930-9062
Tellme Networks, Inc.   1-800-555-TELLFax 650-930-9101
--





Re: Getting ugly: mod_perl and traditional forms of writing CGI

2002-08-08 Thread sully

On 8/8/2002 at 2:44 PM Richard Dice wrote:

>> So the idea when migrating from CGI to mod_perl for this most-finished
> > project was: Change as little as possible.
>
>That's a very sound idea.  But I have a question:  regarding the piece of
>code that you provided here, is that the original code of the forum
>software, or your own hacked-upon version that you've been working on to
>try to get to work with mod_perl?
>
>My guess is the latter.  Here's the secret:  You don't have to do
>ANYTHING to a script to get it to work with mod_perl.  Just leave it
>be.

Yep, it's the latter all right. :) My requirements for this forum are only to 
integrate the user accounts with the site's overall accounts (no problem) and to allow 
people to post medium-length text pieces (around 5000 characters), which has become an 
issue. A good 75% of the time anything over 500 bytes in size submitted through the 
form gets ignored - the data POSTed *is* sent and received (verified by packet 
sniffer), it's just that either Apache or mod_perl doesn't pick this up. All of the 
other scripts (which take in minimal input and do a lot of output) work fine...in my 
limited-user test environment.

What I'm trying to understand is if this Apache/mod_perl input dropping problem is a 
symptom of a great problem that I'll eventually encounter with a large(r) base of 
users. A topic discussed here a few days ago (reread at 
http://mathforum.org/epigone/modperl/strooplexswoi ) sounded exactly like my issue, 
but whereas he apparently found a solution I have not.

>You do have to set up a <...> block of some sort or another, though.
>You can do it with a  block, certainly, but there are errors
>in the  block that you provided in your email.
>
>Think of a  block, roughly speaking, as corresponding to a
>URL (URI, whatever).  What you're saying is that your /cgi-bin URL
>(URI, whatever) should be handled by Apache::Registry.  This is obviously
>no good. :-)  What you should do with your  block might be
>something like this:
>
>
> SetHandler perl-script
> PerlHandler Apache::Registry
> Options ExecCGI
> PerlSendHeader On
>
>
>Specifically, name the full URI (URL, whatever) that you want to be
>handled by the
>
>If you want *every* file in a directory to handled by Apache::Registry,
>then consider using a  block instead.  (Though I wouldn't
>recommend setting something like this up on your /cgi-bin directory,
>as it is kind of special.  Make a /modperl-bin directory and move
>your scripts into there instead, or something like that.)  You should
>brush up on , , and  (and <*Match> versions
>of each) run-time configuration directives at
>
> http://httpd.apache.org/docs/mod/directives.html

Thanks, fixed. :) Hasn't changed the problem outlined above though.

>If your scripts are "dirty" then Apache::Registry might not be a good
>idea.  Use Apache::PerlRun instead in those cases.  You can read more
>about what constitutes a "dirty" scripts in the
>http://perl.apache.org/guide documentation.

99% of the code is running quite enthusiastically...in my test environment. I'll just 
have to see what happens when the load begins to climb.

>I notice that your email address is @rogers.com.  You don't happen
>to live in/around Toronto, do you?  (@rogers.com is big around here.)
>I only ask because then I would suggest that you come out to the
>monthly TPM (Toronto Perl Monger) meetings, so that you can learn
>from & network with other Perl-interested people in the GTA.
>Info is available from http://to.pm.org/  (Regardless of where
>you live, there might be a Perl Monger group in your area.
>Check out http://www.pm.org for a list of established groups.)

Lived in Toronto all my life, recently moved out to Mississauga. I've browsed over the 
T.O. Perl Monger's site but haven't given serious thought to coming down. If I can get 
this lousy site up and going I'll be definitely coming down the next time there's a 
meeting. :)

>Cheers,
>Richard
>
>--
>
>  Richard Dice * Voice 416 841 7365 * Fax 416 841 7364
>  University of Toronto Rotman School of Management MBA Candidate
>  Class of 2004 * ShadNet Creator * http://shadnet.shad.ca
>  Occassional Writer, HotWired / Webmonkey * http://www.webmonkey.com
>  Speaker, Thunderlizard Web Design World Conferences
>* http://www.thunderlizard.com

S. Syed


--
"A computer lets you make more mistakes faster than any invention
in human history - with the possible exceptions of handguns and
tequila."
-- Mitch Ratliffe