[Catalyst-dev] Catalist::Engine::Apache registry script condition

Iván Chavero ichavero at uach.mx
Thu Nov 23 21:59:12 GMT 2006


Hello,

There's a problem with the current way of checking if
Catalist::Engine::Apache is running as a mod_perl handler or as a
registry script. Currently it checks if the filename() method of the
request object with this statement:

if ( $self->apache->filename && -f $self->apache->filename && -x _ )

The problem is that if a handler in a previous request stage (like
PerlAuthenHandler) assings a value to the filename of the request object
that condition is going to be truth and the $base_path is going to be
modified incorrectly.

So i thougth that the proper way of checking if Catalist::Engine::Apache
is running as a registry script should be checking the return value of
the handler() method of the request object (which is available in both
mod_perl 1.3, 1.99 and 2.0). If the value returned is perl-script, then
it is a registry script anything else is a handler.

I hope this little patch is found useful (generated from the current svn
tree with this command svn di > Apache.pm.patch):


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


Index: trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm
===================================================================
--- trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm
(revision 5590)
+++ trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm  (working
copy)
@@ -107,7 +107,7 @@

     # Are we an Apache::Registry script? Why anyone would ever want to run
     # this way is beyond me, but we'll support it!
-    if ( $self->apache->filename && -f $self->apache->filename && -x _ ) {
+    if ( $self->apache->handler() eq "perl-script" ) {
         $base_path .= $ENV{SCRIPT_NAME};
     }



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



By the way it was a joy to read the code!!!
Keep on the great work


-- 
Iván Chavero
Administrador de Sistemas UNIX
CGTI/DSE
Universidad Autónoma de Chihuahua
ichavero at uach.mx
http://cgti.uach.mx
Tel. 614 439 18 35 ext 1728




More information about the Catalyst-dev mailing list