Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

flash and Template::Stash::ForceUTF8

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


ankolev at gmail

May 17, 2008, 12:57 AM

Post #1 of 2 (242 views)
Permalink
flash and Template::Stash::ForceUTF8

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

Here is the line of Template::Stash::ForceUTF8:

sub get {
my $self = shift;
my $result = $self->SUPER::get(@_); ### Line 12
return $result if ref $result;

Encode::_utf8_on($result) unless Encode::is_utf8($result);
return $result;
}

Is this a bug or the problem is in my code?
Thanks

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


moseley at hank

May 17, 2008, 7:36 AM

Post #2 of 2 (215 views)
Permalink
Re: flash and Template::Stash::ForceUTF8 [In reply to]

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


_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.