[rt-devel] Using RT with HTML::Mason::ApacheHandler( args_method => 'mod_perl' )

Jesse Vincent jesse at bestpractical.com
Wed Feb 20 21:02:08 EST 2002


I think I'd prefer to apply this change to the current development branch (RT 2.1)
 rather than the current stable branch. 


One way to deal with an existing setup that needs a different mason config is 
to run a seperate backend apache for RT or to use FastCGI for RT.  Various
large mod_perl apps (RT included) really seem to prefer that they run on 
seperate apache instances.  Also, I'm not convinced that you can't easily
access RT's internal configuration data from another application...which
could reveal sensitive information if non-administrators have the ability
to define code which will be executed in the mod_perl environment.

	-j

On Wed, Feb 20, 2002 at 12:19:48PM +0300, Alexei Barantsev wrote:
> Hello,
> 
> Use of RT with (args_method => 'CGI') and (args_method => 'mod_perl') differ
> in attachments uploading. The matter is that you cannot call $m->cgi_object
> if you use (args_method => 'mod_perl'). You should use Apache::Request to
> upload attachments instead of CGI object.
> 
> Here is a patch that manages RT to work with both CGI and mod_perl methods.
> 
> <LYRICAL_DIGRESSION>
> Why do I need (args_method => 'mod_perl'), why don't use suggested by
> default (args_method => 'CGI')? I'm not a performance crazy. The reason is
> that I have installed RT on the site where Mason works already for a long
> time with (args_method => 'mod_perl'). You know that this is an option of
> module import. So if the module has already loaded from main server
> configuration with (args_method => 'mod_perl') I can't change this setting.
> May be it is possible to change this on per-VirtualHost or per-request
> basis? Any suggestions would be greatly appeciated.
> </LYRICAL_DIGRESSION>
> 
> bash$ diff -u ~/original/rt-2-0-12-pre4/lib/RT/Interface/Web.pm
> /usr/local/rt2/lib/RT/Interface/Web.pm
> --- /home/barancev/original/rt-2-0-12-pre4/lib/RT/Interface/Web.pm      Tue
> Feb 19 02:00:19 2002
> +++ /usr/local/rt2/lib/RT/Interface/Web.pm      Wed Feb 20 11:14:57 2002
> @@ -317,11 +317,14 @@
>          Data    => [ $args{'Body'} ]
>      );
> 
> -    my $cgi_object = CGIObject();
> -    if ( $cgi_object->param( $args{'AttachmentFieldName'} ) ) {
> -
> -        my $cgi_filehandle =
> -          $cgi_object->upload( $args{'AttachmentFieldName'} );
> +    my ($cgi_object, $ar);
> +    if ($HTML::Mason::ApacheHandler::ARGS_METHOD eq '_cgi_args') {
> +        $cgi_object = CGIObject();
> +    } else {
> +        use Apache::Request;
> +        $ar = new Apache::Request($r);
> +    }
> +    if ( ($cgi_object || $ar)->param( $args{'AttachmentFieldName'} ) ) {
> 
>          use File::Temp qw(tempfile tempdir);
> 
> @@ -333,22 +336,33 @@
> 
>          # We're having trouble with tempfiles not getting created. Let's
> try it with
>          # a scalar instead
> +
> +        my ($filehandle, $filename, $content_type);
> +        if ($cgi_object) {
> +            $filehandle = $cgi_object->upload(
> $args{'AttachmentFieldName'} );
> +            $filename = "$filehandle";
> +            my $uploadinfo = $cgi_object->uploadInfo($filehandle);
> +            $content_type = $upload->info('Content-Type');
> +        } else {
> +            my $upload = $ar->upload($args{'AttachmentFieldName'});
> +            $filehandle = $upload->fh;
> +            $filename = $upload->filename;
> +            $content_type = $upload->info('Content-Type');
> +        }
> 
>          my ($buffer, at file);
> 
> -        while ( my $bytesread = read( $cgi_filehandle, $buffer, 4096 ) ) {
> +        while ( my $bytesread = read( $filehandle, $buffer, 4096 ) ) {
>              push(@file, $buffer);
>          }
> 
>          $RT::Logger->debug($file);
> -        my $filename = "$cgi_filehandle";
>          $filename =~ s#^(.*)/##;
> -        my $uploadinfo = $cgi_object->uploadInfo($cgi_filehandle);
>          $Message->attach(
>              Data    => \@file,
>              #Path     => $temp_file,
>              Filename => $filename,
> -            Type     => $uploadinfo->{'Content-Type'}
> +            Type     => $content_type
>          );
>          #close($fh);
>          #unlink($temp_file);
> 
> 
> 
> Best regards,
> Alexei
> 
> --
> Alexei Barantsev, ISP RAS
> E-mail: barancev at kazbek.ispras.ru
> ICQ   : 3959207
> 
> 
> _______________________________________________
> rt-devel mailing list
> rt-devel at lists.fsck.com
> http://lists.fsck.com/mailman/listinfo/rt-devel
> 

-- 
http://www.bestpractical.com/products/rt  -- Trouble Ticketing. Free.




More information about the Rt-devel mailing list