Code fix/suggestion after MP2 update

[prev] [thread] [next] [Date index for 2005/04/30]

From: cfaust-dougot
Subject: Code fix/suggestion after MP2 update
Date: 13:27 on 30 Apr 2005
This is a multi-part message in MIME format.

------_=_NextPart_001_01C54D88.53E4ADEB
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Folks,
=20
I hope my brain is just not functioning properly yet as its Saturday, =
but I'm having a tough time figuring out the best way to handle the =
needed changed of "Apache::*" to  "Apache2::Const*" automatically so I =
don't have to edit anything with a script going up on 2 different =
servers with 2 the 2 different MP2 installs.
=20
The code that was effected for me was simple enough, all my handler's =
are just:
=20
=20
sub handler {
 $r =3D shift;
=20
 my $request_type  =3D anything
=20
 if ($request_type eq 'Apache::REDIRECT') {
  $r->headers_out->set(Location =3D> $back_url);
     #return Apache2::Const::REDIRECT;
    # or
     return Apache::REDIRECT;
 } else {
  #return Apache::OK;
  # or
 return Apache2::Const::OK;
 }
=20
}
=20
I thought it would be nice and easy to do it with a PerlSetVar in the =
conf file, so I would have something like
=20
in conf:
PerlSetVar ApacheReturnRedirect Apache::REDIRECT
PerlSet....
=20
In handler
  if ($request_type eq 'Apache::REDIRECT') {
   $r->headers_out->set(Location =3D> $back_url);
      return $r->dir_config->get('ApacheReturnRedirect');
  } else {
   return $r->dir_config->get('ApacheReturnOk');
  }

But that didn't work, got an error of Argument "Apache::REDIRECT" isn't =
numeric, I also can't do it within any sort of "if" statement in the =
script itself as I will get the error of "Apache::* not allowed while =
script subs...".
=20
Any suggestions?
=20
Thanks In Advance!
-Chris
=20

------_=_NextPart_001_01C54D88.53E4ADEB
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML =
DIR=3Dltr><HEAD><META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1"></HEAD><BODY><DIV><FONT face=3D'Arial' =
color=3D#000000 size=3D2>Folks,</FONT></DIV>=0A=
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>=0A=
<DIV><FONT face=3DArial size=3D2>I hope my brain is just not functioning =
properly =0A=
yet as its Saturday, but I'm having a tough time figuring out the best =
way to =0A=
handle the needed changed of "Apache::*" to &nbsp;"Apache2::Const*" =0A=
automatically so I don't have to edit anything with a script going up on =
2 =0A=
different servers with 2 the 2 different MP2 installs.</FONT></DIV>=0A=
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>=0A=
<DIV><FONT face=3DArial size=3D2>The code that was effected for me was =
simple =0A=
enough, all my handler's&nbsp;are just:</FONT></DIV>=0A=
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>=0A=
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>=0A=
<DIV>sub handler {<BR>&nbsp;$r =3D shift;</DIV>=0A=
<DIV>&nbsp;</DIV>=0A=
<DIV>&nbsp;my $request_type&nbsp; =3D anything</DIV>=0A=
<DIV>&nbsp;</DIV>=0A=
<DIV>&nbsp;if ($request_type eq 'Apache::REDIRECT') =0A=
{<BR>&nbsp;&nbsp;$r-&gt;headers_out-&gt;set(Location =3D&gt; =0A=
$back_url);<BR>&nbsp;&nbsp;&nbsp; &nbsp;#return =
Apache2::Const::REDIRECT;</DIV>=0A=
<DIV>&nbsp;&nbsp;&nbsp; # or</DIV>=0A=
<DIV>&nbsp;&nbsp;&nbsp;&nbsp; return Apache::REDIRECT;<BR>&nbsp;} else =0A=
{<BR>&nbsp;&nbsp;#return Apache::OK;</DIV>=0A=
<DIV>&nbsp; # or</DIV>=0A=
<DIV>&nbsp;return Apache2::Const::OK;<BR>&nbsp;}</DIV>=0A=
<DIV>&nbsp;</DIV>=0A=
<DIV>}</DIV>=0A=
<DIV>&nbsp;</DIV>=0A=
<DIV>I thought it would be nice and easy to do it with a PerlSetVar in =
the conf =0A=
file, so I would have something like</DIV>=0A=
<DIV>&nbsp;</DIV>=0A=
<DIV>in conf:</DIV>=0A=
<DIV>PerlSetVar ApacheReturnRedirect Apache::REDIRECT</DIV>=0A=
<DIV>PerlSet....</DIV>=0A=
<DIV>&nbsp;</DIV>=0A=
<DIV>In handler</DIV>=0A=
<DIV>&nbsp;&nbsp;if ($request_type eq 'Apache::REDIRECT') =0A=
{<BR>&nbsp;&nbsp;&nbsp;$r-&gt;headers_out-&gt;set(Location =3D&gt; =0A=
$back_url);<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;return =0A=
$r-&gt;dir_config-&gt;get('ApacheReturnRedirect');<BR>&nbsp;&nbsp;} else =0A=
{<BR>&nbsp;&nbsp;&nbsp;return =0A=
$r-&gt;dir_config-&gt;get('ApacheReturnOk');<BR>&nbsp;&nbsp;}<BR></DIV>=0A=
<DIV>But that didn't work, got an error of Argument "Apache::REDIRECT" =
isn't =0A=
numeric, I also can't do it within any sort of "if" statement in the =
script =0A=
itself as I will get the error of "Apache::* not allowed while script =0A=
subs...".</DIV>=0A=
<DIV>&nbsp;</DIV>=0A=
<DIV>Any suggestions?</DIV>=0A=
<DIV>&nbsp;</DIV>=0A=
<DIV>Thanks In Advance!</DIV>=0A=
<DIV>-Chris</DIV>=0A=
<DIV>&nbsp;</DIV></BODY></HTML>
------_=_NextPart_001_01C54D88.53E4ADEB--

Code fix/suggestion after MP2 update
cfaust-dougot 13:27 on 30 Apr 2005

Re: Code fix/suggestion after MP2 update
Stas Bekman 15:53 on 30 Apr 2005

RE: Code fix/suggestion after MP2 update
cfaust-dougot 21:57 on 30 Apr 2005

Re: Code fix/suggestion after MP2 update
Stas Bekman 22:42 on 30 Apr 2005

Generated at 15:53 on 25 May 2005 by mariachi v0.52