[Catalyst] flash and Template::Stash::ForceUTF8

Bill Moseley moseley at hank.org
Sat May 17 15:36:01 BST 2008

On Sat, May 17, 2008 at 10:57:36AM +0300, Angel Kolev wrote:
> Hello, group.
> I use 'flash' to share some params across the sessions and then redirect.
> sub edit : Local {
>    my ( $self, $c) = @_;
>    my $edit = $c->request->params->{section}|| $c->flash->{section}|| "";
>    ....
>    ....
>    $c->flash->{section} ='Pricing';
>    $c->res->redirect($c->uri_for('/clients/edit')); # redirect to the 
> same place but with different params
> }
> I use Template::Stash::ForceUTF8 and get following error when i try to 
> fetch $edit:
> undef error - flash takes a hash or hashref at 
> /usr/local/share/perl/5.8.8/Template/Stash/ForceUTF8.pm line 12

Are you sure you want ForceUTF8?  Doesn't that just force the utf8
flag?  If that's the case then I'd look more closely at why you have
non-decoded strings in variables and instead make sure your input is
decoded correctly when the data is fetched from outside your program.

If your templates are UTF8 then you can tell TT to decode the
templates automatically with ENCODING => 'UTF-8'.

I'd also be careful with "flash" as reading flash clears everything in
the flash, IIRC.  I tend to just "delete $c->session->{foo}".

Bill Moseley
moseley at hank.org

More information about the Catalyst mailing list