Re: Code fix/suggestion after MP2 update
cfaust-dougot wrote: Folks, 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. The code that was effected for me was simple enough, all my handler's are just: sub handler { $r = shift; my $request_type = anything if ($request_type eq 'Apache::REDIRECT') { $r->headers_out->set(Location => $back_url); #return Apache2::Const::REDIRECT; # or return Apache::REDIRECT; } else { #return Apache::OK; # or return Apache2::Const::OK; } } I thought it would be nice and easy to do it with a PerlSetVar in the conf file, so I would have something like in conf: PerlSetVar ApacheReturnRedirect Apache::REDIRECT PerlSet In handler if ($request_type eq 'Apache::REDIRECT') { $r->headers_out->set(Location => $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 -- __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
RE: Code fix/suggestion after MP2 update
Title: Re: Code fix/suggestion after MP2 update cfaust-dougot wrote:>>> Folks,>>> >>> 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.>>> >>> The code that was effected for me was simple enough, all my handler's are just:>>> >>> >>> sub handler {> >> $r = shift;> >>>>> my $request_type = anything>>> >>> if ($request_type eq 'Apache::REDIRECT') {>>> $r->headers_out->set(Location => $back_url);>>> #return Apache2::Const::REDIRECT;>>> # or>>> return Apache::REDIRECT;>>> } else {>>> #return Apache::OK;>>> # or>>> return Apache2::Const::OK;>>> }>>> >>> }>>> >>> I thought it would be nice and easy to do it with a PerlSetVar in the conf file, so I would have something like>>> >>> in conf:>>> PerlSetVar ApacheReturnRedirect Apache::REDIRECT>>> PerlSet>>> >>> In handler>>> if ($request_type eq 'Apache::REDIRECT') {>>> $r->headers_out->set(Location => $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. -Chris
Re: Code fix/suggestion after MP2 update
cfaust-dougot wrote: 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. Why preprocessing? Just replace those with Apache::Const::OK or whatever is needed. See the fixme script above. -- __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com