Using PerlTypeHandler and PerlHandler for the same Location

2001-08-08 Thread Jay Buffington

Hi,

In my httpd.conf file I have: 
Location /foo/
SetHandler perl-script
PerlTypeHandler foo
PerlHandler bar
/Location

and then in the foo and bar files I have: 

--file foo.pm-
package foo;

sub handler {
my $r = shift;

$r-log_error(I'm in foo.);
}
1;


--file bar.pm-
package bar; 

sub handler {
my $r = shift;

$r-log_error(I'm in bar.);
}
1;


I would expect this experiment would print out I'm in foo. followed by I'm in bar. 
to my apache error log.  It only prints I'm in foo.  If I remove the PerlTypeHandler 
line from the httpd.conf I get only I'm in bar.  If I leave the TypeHandler but omit 
the PerlHandler, and add $r-push_handlers(PerlHandler=\bar::handler); to foo.pm I 
still only get I'm in foo.

I'm using Perl 5.6 and mod_perl 1.25 with apache 1.3.19 

Why does this not work as I expected?

Thanks.
Jay Buffington



Using PerlLogHandler to write errors to database

2001-07-16 Thread Jay Buffington

Hi,

I want to write a PerlLogHandler to write all errors to a database.  The database 
table will probably look like this:

CREATE TABLE error_log (
when DATETIME not null,
remotehost VARCHAR (255) not null,
virtualhost VARCHAR (255),
severity ENUM ('emerg', 'alert', 'crit', 'error', 'warn',
   'notice', 'info', 'debug') not null DEFAULT 'error',
error TEXT not null
);

I couldn't find any answers to my three important questions:

Is an error being logged?
What is the severity of the error?
What is the error?

Is there away to get this information from the request object?

Thanks,
Jay



Re: Apache::Upload filehandle

2001-07-13 Thread Jay Buffington

Okay, that didn't fix the problem, but I have figured it out.  

Apache::Upload returns the filehandle as being blessed into Apache::Upload.  Whenever 
I send the filehandle to Image::Magick it thinks that it is a url of type Apache: 
(kind of like file: or http:).  If I bless the filehandle into a class that does not 
have a colon in it, it works.  

Here is my work around:

8... *snip*

my $fh = $r-upload-fh;
bless $fh, nonexistantclass;
my $error = $image-Read(file=$fh);

8... *snip*


I guess that this is a bug in Apache::Upload and Image::Magick.  Apache::Upload should 
not return the filehandle as blessed (I'm confused why it does this in the first 
place) and Image::Magick should do a better job checking to see if it has been sent a 
filehandle.  

Can this please be fixed in the next release of libapreq?

Thanks,
Jay Buffington 


On Thu, Jul 12, 2001 at 10:03:24AM -0400, darren chamberlain wrote:
 Jay Buffington [EMAIL PROTECTED] said something to this effect on 07/11/2001:
  I'm trying to use image magick to manipulate images that are
  uploaded via http.  To handle the uploaded images I'm using
  libapreq's Apache::Upload.
  
  I wrote the below simple example script to help explain my problem.
  
  When an image is uploaded to it I get this error in the apache
  error log: ImageMagick error: Warning 320: no delegate for this
  image format (:Upload=GLOB(0x873bcec)) [No such file or
  directory]
  
  I'm confused why this happens.  Could someone please explain
  this behaviour to me? 
 
 This looks like $r-upload-fh is being stringified, probably
 because of the context.  What happens when you assign the glob
 returned by $r-upload-fh to a lexical scalar, and then pass
 that into $image-Read()?  I hit this a few days ago, when
 passing a glob reference into a subroutine (not
 mod_perl-related), and this is the only thing that worked.
 
  
  package UploadFile;
  
  use Apache;
  use Apache::Request;
  use Apache::Constants qw(:common);
  use CGI qw(-compile :standard);
  use Image::Magick;
  
  sub handler {
  my $r = new Apache::Request(shift);
  
  if ($r-param('action') eq upload) {
  my $image = new Image::Magick;
 
 Add these changes: 
 
   my $fh = $r-upload-fh;
   my $error = $image-Read(file = $fh);
 
  $r-log_error(ImageMagick error: $error) if $error;
  $r-print(image geometry:  . join  x ,
$image-Get('width', 'height'));
  undef $image;
  }
  
  $r-print(start_html() . start_multipart_form() . Upload an image:  .
filefield(-name=uploadedfile) . submit(-name=action,
-value=upload) . end_form() . end_html());
  
  return OK;
  }
  
  1;
 
 (darren)
 
 -- 
 Death to all fanatics!



Apache::Upload filehandle

2001-07-11 Thread Jay Buffington

I'm trying to use image magick to manipulate images that are uploaded via http.  To 
handle the uploaded images I'm using libapreq's Apache::Upload.

I wrote the below simple example script to help explain my problem.

When an image is uploaded to it I get this error in the apache error log: 
ImageMagick error: Warning 320: no delegate for this image format 
(:Upload=GLOB(0x873bcec)) [No such file or directory]

I'm confused why this happens.  Could someone please explain this behaviour to me? 


package UploadFile;

use Apache;
use Apache::Request;
use Apache::Constants qw(:common);
use CGI qw(-compile :standard);
use Image::Magick;

sub handler {
my $r = new Apache::Request(shift);

if ($r-param('action') eq upload) {
my $image = new Image::Magick;
my $error = $image-Read(file=$r-upload()-fh());
$r-log_error(ImageMagick error: $error) if $error;
$r-print(image geometry:  . join  x , $image-Get('width', 'height'));
undef $image;
}

$r-print(start_html() . start_multipart_form() . Upload an image:  . 
filefield(-name=uploadedfile) . submit(-name=action, -value=upload) . 
end_form() . end_html());

return OK;
}

1;




returning one instance of an object per request

2001-07-06 Thread Jay Buffington

Hi,

I'm building a web application that has a User perl module.  I have several other perl 
modules that need to know the user id of the current logged in user (or 0 for a guest 
user).  I was thinking that I could write the User class in such a way that every time 
(except the first) a constructor was called the same instance of the user object would 
be returned for each apache request.  

Is this the best way to go about solving my problem?  If so what's the best way to 
implement this?  Or maybe I should just pass around the user id to every class?  I'd 
perfer to avoid this if possible. 

Thanks,
Jay