RE: Code fix/suggestion after MP2 update

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

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

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

cfaust-dougot wrote:
>>> 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;
> >>
>>>  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...".
> >>
>>> Any suggestions?

>That's funky :) But you can't do that. Since those constants are really
>subroutines. What you are returning are strings, so you will need to =
eval
>those before using those. The best run the script that will adjust the
>constants: http://people.apache.org/~geoff/fixme

Thanks Stas, I was hoping to avoid any sort of preprocessing but if =
that's what it takes so you guys can keep producing  lighting in a =
bottle, I'm not going to complain.
=20
-Chris
=20

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

<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">=0A=
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">=0A=
<HTML>=0A=
<HEAD>=0A=
=0A=
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.5.7226.0">=0A=
<TITLE>Re: Code fix/suggestion after MP2 update</TITLE>=0A=
</HEAD>=0A=
<BODY>=0A=
<DIV dir=3Dltr><FONT size=3D2>cfaust-dougot wrote:<BR>&gt;&gt;&gt; =0A=
Folks,<BR>&gt;&gt;&gt;&nbsp;<BR>&gt;&gt;&gt; I hope my brain is just not =0A=
functioning properly yet as its Saturday, but I'm having a tough time =
figuring =0A=
out the best way to handle the needed changed of "Apache::*" to&nbsp; =0A=
"Apache2::Const*" automatically so I don't have to edit anything with a =
script =0A=
going up on 2 different servers with 2 the 2 different MP2 =0A=
installs.<BR>&gt;&gt;&gt;&nbsp;<BR>&gt;&gt;&gt; The code that was =
effected for =0A=
me was simple enough, all my handler's are =0A=
just:<BR>&gt;&gt;&gt;&nbsp;<BR>&gt;&gt;&gt;&nbsp;<BR>&gt;&gt;&gt; sub =
handler =0A=
{<BR>&gt;&nbsp;&gt;&gt; $r =3D =
shift;<BR>&gt;&nbsp;&gt;&gt;<BR>&gt;&gt;&gt;&nbsp; =0A=
my $request_type&nbsp; =3D =
anything<BR>&gt;&gt;&gt;&nbsp;<BR>&gt;&gt;&gt;&nbsp; if =0A=
($request_type eq 'Apache::REDIRECT') {<BR>&gt;&gt;&gt;&nbsp;&nbsp; =0A=
$r-&gt;headers_out-&gt;set(Location =3D&gt; =0A=
$back_url);<BR>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #return =0A=
Apache2::Const::REDIRECT;<BR>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; # =0A=
or<BR>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return =0A=
Apache::REDIRECT;<BR>&gt;&gt;&gt;&nbsp; } else =
{<BR>&gt;&gt;&gt;&nbsp;&nbsp; =0A=
#return Apache::OK;<BR>&gt;&gt;&gt;&nbsp;&nbsp; # =
or<BR>&gt;&gt;&gt;&nbsp; =0A=
return Apache2::Const::OK;<BR>&gt;&gt;&gt;&nbsp; =0A=
}<BR>&gt;&gt;&gt;&nbsp;<BR>&gt;&gt;&gt; =
}<BR>&gt;&gt;&gt;&nbsp;<BR>&gt;&gt;&gt; =0A=
I thought it would be nice and easy to do it with a PerlSetVar in the =
conf file, =0A=
so I would have something like<BR>&gt;&gt;&gt;&nbsp;<BR>&gt;&gt;&gt; in =0A=
conf:<BR>&gt;&gt;&gt; PerlSetVar ApacheReturnRedirect =0A=
Apache::REDIRECT<BR>&gt;&gt;&gt; =0A=
PerlSet....<BR>&gt;&gt;&gt;&nbsp;<BR>&gt;&gt;&gt; In =0A=
handler<BR>&gt;&gt;&gt;&nbsp;&nbsp; if ($request_type eq =
'Apache::REDIRECT') =0A=
{<BR>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp; $r-&gt;headers_out-&gt;set(Location =
=3D&gt; =0A=
$back_url);<BR>&gt;&nbsp;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return =0A=
$r-&gt;dir_config-&gt;get('ApacheReturnRedirect');<BR>&gt;&gt;&gt;&nbsp;&=
nbsp; } =0A=
else {<BR>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp; return =0A=
$r-&gt;dir_config-&gt;get('ApacheReturnOk');<BR>&gt;&gt;&gt;&nbsp;&nbsp; =0A=
}<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; But that didn't work, got an error of =
Argument =0A=
"Apache::REDIRECT" isn't numeric, I also can't do it within any sort of =
"if" =0A=
statement in the script itself as I will get the error of "Apache::* not =
allowed =0A=
while script subs...".<BR>&gt;&nbsp;&gt;&gt;<BR>&gt;&gt;&gt; Any =0A=
suggestions?<BR><BR>&gt;That's funky :) But you can't do that. Since =
those =0A=
constants are really<BR>&gt;subroutines. What you are returning are =
strings, so =0A=
you will need to eval<BR>&gt;those before using those. The best run the =
script =0A=
that will adjust the<BR>&gt;constants: <A =0A=
href=3D"http://people.apache.org/~geoff/fixme">http://people.apache.org/~=
geoff/fixme</A><BR></FONT></DIV>=0A=
<DIV dir=3Dltr><FONT size=3D2>Thanks Stas, I was hoping to avoid any =
sort of =0A=
preprocessing but if that's what it takes so you guys can keep =
producing&nbsp; =0A=
lighting in a bottle, I'm not going to complain.</FONT></DIV>=0A=
<DIV dir=3Dltr><FONT size=3D2></FONT>&nbsp;</DIV>=0A=
<DIV dir=3Dltr><FONT size=3D2>-Chris</FONT></DIV>=0A=
<DIV dir=3Dltr><FONT size=3D2>&nbsp;</DIV></FONT>=0A=
=0A=
</BODY>=0A=
</HTML>
------_=_NextPart_001_01C54DCF.A754FD7C--

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