You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Gregory Matthews <gr...@iwebtips.com> on 2002/05/22 05:23:40 UTC

Perl written in mod_perl

Here's an odd question for you.  Why is it when I go to places like 
cgi-resources.com and other cgi repositories, mod_perl applications are far 
and few between...commercially that is?

All I see are common cgi scripts written in plain perl.

Does it have anything to do with the configurability tasks involved on the 
customers box, i.e., once the sale is made?

If this is the wrong place for a question like this, I apologize.  Just 
curious.

Gregory



Re: Image::Size, TT, and mod_perl Question

Posted by Perrin Harkins <pe...@elem.com>.
>      my %vars = {TOO_WIDE => 1};

That isn't doing what you think it's doing.  Try this:

my $vars = { 'TOO_WIDE' => 1 };

[OT] Re: Image::Size, TT, and mod_perl Question

Posted by "Ken Y. Clark" <kc...@logsoft.com>.
On Tue, 21 May 2002, Mike Melillo wrote:

Hey, Mikey!

> Date: Tue, 21 May 2002 23:28:29 -0400
> From: Mike Melillo <mm...@attbi.com>
> To: modperl@apache.org
> Subject: Image::Size, TT, and mod_perl Question
>
>
>
> I posed this question to the Template Toolkit list and got no response,
> so I figured I'd give this list a shot...
>
>
> ---------------------
>
> Hello, below is some code I have in a mod_perl handler that checks to
> see if an uploaded image is less than 300 pixels tall or wide.
> Everything seems to be working except the fact that the template is not
> returning with the proper values processed.  Below is the code and the
> err_log output when I output an image that is too wide.
>
>
> [snip]
> my $upload = $r->upload;
> my $type        = $upload->type;
> my $fh          = $upload->fh;
> my $username    = $r->param('username');
>
>
> my ($x, $y) = imgsize($fh);
> print STDERR Dumper($x);
> print STDERR Dumper($y);
>
> unless ($x < 300) {
> print STDERR "the greater than works\n";
>      # This checks to make sure the image isnt more than 300 x 300
>      my %vars = {TOO_WIDE => 1};

You're creating the hash incorrectly.  Do either:

    my %vars = ( TOO_WIDE => 1 );
    or
    my $vars = { TOO_WIDE => 1 };

ky


>      my $config = {
>                 INCLUDE_PATH => '/moc/html/templates',
>                 POST_CHOMP => 1,
>                 EVAL_PERL => 1,
>      };
>
>      my $template = Template->new($config) || die "New Template Failed:
> $!\n";
>
>         #the process method prints the template out to the browser via
> $r
>         $template->process('pic_upload.tt2', \%vars, $r) || do {
>           $r->log_reason($template->error());
>           return SERVER_ERROR;
>         };
>         return OK;
>
> } # end of X/Y coordinate if
>
> [snip]
>
> The err_log output:
>
> $VAR1 = 310;
> $VAR1 = 72;
> the greater than works
>
> [end of err_log]
>
> The problem is the template pic_upload.tt2 has this in it:
>
> [% IF TOO_WIDE %]
> <font color=red>Your File was too big.  Make it under 30K</font><p> [%
> END %]
>
> But that isn't showing up.  I do the almost identical thing immediately
> after this if clauses to check if the file's type is a jpeg.  That
> works, so I don't understand what I pasted in wrong, or forgot to paste
> in.
>
> Mike
>
>
>
>

-- 
# -----------------------------
# k e n            Ken Y. Clark
# r   y      kclark@logsoft.com
# a l c            972-542-7923
# -----------------------------


Image::Size, TT, and mod_perl Question

Posted by Mike Melillo <mm...@attbi.com>.

I posed this question to the Template Toolkit list and got no response,
so I figured I'd give this list a shot...


---------------------

Hello, below is some code I have in a mod_perl handler that checks to
see if an uploaded image is less than 300 pixels tall or wide.
Everything seems to be working except the fact that the template is not
returning with the proper values processed.  Below is the code and the
err_log output when I output an image that is too wide.


[snip] 
my $upload = $r->upload;
my $type        = $upload->type;
my $fh          = $upload->fh;
my $username    = $r->param('username');


my ($x, $y) = imgsize($fh);
print STDERR Dumper($x);
print STDERR Dumper($y);

unless ($x < 300) {
print STDERR "the greater than works\n";
     # This checks to make sure the image isnt more than 300 x 300
     my %vars = {TOO_WIDE => 1};
     my $config = {
                INCLUDE_PATH => '/moc/html/templates',
                POST_CHOMP => 1,
                EVAL_PERL => 1,
     };

     my $template = Template->new($config) || die "New Template Failed:
$!\n";

        #the process method prints the template out to the browser via
$r
        $template->process('pic_upload.tt2', \%vars, $r) || do {
          $r->log_reason($template->error());
          return SERVER_ERROR;
        };
        return OK;

} # end of X/Y coordinate if

[snip]

The err_log output:

$VAR1 = 310;
$VAR1 = 72;
the greater than works

[end of err_log]

The problem is the template pic_upload.tt2 has this in it:

[% IF TOO_WIDE %]
<font color=red>Your File was too big.  Make it under 30K</font><p> [%
END %]

But that isn't showing up.  I do the almost identical thing immediately
after this if clauses to check if the file's type is a jpeg.  That
works, so I don't understand what I pasted in wrong, or forgot to paste
in.

Mike





Re: Perl written in mod_perl

Posted by "Peter J. Schoenster" <pe...@schoenster.com>.
On 21 May 2002 at 22:23, Gregory Matthews wrote:

> Here's an odd question for you.  Why is it when I go to places like
> cgi-resources.com and other cgi repositories, mod_perl applications
> are far and few between...commercially that is?
> 
> All I see are common cgi scripts written in plain perl.
> 
> Does it have anything to do with the configurability tasks involved on
> the customers box, i.e., once the sale is made?
> 
> If this is the wrong place for a question like this, I apologize. 
> Just curious.

I think it's a good question.  Unlike I reckon most people on this 
list, I live in a virtual world.  I started my first programming job 
at an ad agency and even the site we did for FedEx went on a virtual 
server.  I think the vast majority of people out there are also 
running virtual servers.  Only recently did the company we host at 
offer mod_perl as an option.  

But then to offer an application for the public at large (not just to 
mod_perl developers)  to download and install ... well, that's 
another beast. Always best to look at those with some expertise. 
Extropia for example. I downloaded their ProjectTracker and it was a 
cgi installation (and made extremely easy to install). I didn't look 
but I bet I could turn it into a handler. I took their experience and 
turned my image gallery application into a cgi application. Anyone 
who knows can turn the cgi handlers into mod_perl handlers otherwise 
it will work in standard cgi environment or under Apache::Registry. 
Even so, when helping people (and usually people for whom an ftp gui 
is "tech") install cgi applications on virtual servers is rarely 
simple. 

Even today I cannot run most of the large scale mod_perl applications 
as I'm still using virtual servers and most of the mod_perl apps 
require a greater degree of control than I have. 

PHP on the other hand, it's everywhere. I have a link to a PHP image 
gallery on my site that is quite nice. I offer it as an alternative 
to my application . It can be installed from the web browser. I have 
installed Perl cgi applications where that was been done as well. I 
cannot imagine doing that for mod_perl applications though.

In short, mod_perl applications using handlers has a very dedicated 
and passionate but limited audience imho.


Peter
-- http://www.readbrazil.com/
Answering Your Questions About Brazil