Ryan wrote:
> in my autohandler I have this filter block to convert English to  
> Spanish:
>
> <%filter>
> if ($session{langauge} eq "espagnol" ){
>
> # Convert from characters to bytes if necessary.
> $_ = encode_utf8( $_ ) if is_utf8( $_ );
> $r->set_content_length( length $_ );
> if (1) {
>       my $uri = $r->uri;
>       foreach my $key (keys %{$en2es{$uri}}) {
>               
> s{(<(?:div|span|td|a|li|p|h1|h2|h3|h4|br|b|th|caption)[^>>]*[>>] 
> [^<<]*)$key([^<]*[<</]{1,2}(?:div|span|td|a|li|p|h1|h2|h3|h4|br|b|th| 
> caption))} {$1$en2es{$uri}->{$key}$2}gis;
>               }
>       foreach my $key (keys %{$en2es{all}}) {
>               
> s{(<(?:div|span|td|a|li|p|h1|h2|h3|h4|br|b|th|caption)[^>>]*[>>] 
> [^<<]*)$key([^<]*[<</]{1,2}(?:div|span|td|a|li|p|h1|h2|h3|h4|br|b|th| 
> caption))} {$1$en2es{all}->{$key}$2}gis;
>
>               }       
>       }
>   }
>
> </%filter>
>
> if $session{langauge} eq "espagnol" it doesn't filter.  If I switch  
> it to if (1) it works.  %session is globally defined in httpd.conf.   
> What's the problem?  Can I not access $session{langauge} from a  
> filter block?
>   

I don't have any problems accessing my global %session variable in my 
filter blocks.

If this were the case then it would be a variable scoping problem and 
you would see an error like the following in your web server logs: 
"Global symbol "%session" requires explicit package name at /foo line 
X."  If you don't see something like this then perl isn't having a 
problem accessing your variable.

Try creating a simpler example so that you can make sure the problem is 
where you think it is:

    <html>
        Language: <% $session{language} %><br />
        Localized Greeting Goes Here:
    </html>
    <%filter>
    if ($session{language} eq 'espagnol') {
        $_ .= ' hola'; # Append a simple greeting
    } else {
        $_ .= ' hello';
    }
    </%filter>


Your output should say something like this:

    $session{lauguage}: espagnol
    Localized Greeting Goes Here:  hola


View source should look like this:

    <html>
        $session{effsitecode}: CTC</br>
        Greeting Goes Here:
    </html>
     hello


This will tell you if the problem is in the main filtering code or if 
it's in the code that sets the session{language}.

Good Luck,

-- Ben

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to