[Catalyst] TT2 list context and DBIx::Class resultsets: solved?
Michele Beltrame
mb at italpro.net
Thu Jun 22 15:40:26 CEST 2006
Hello!
While investigating the (usual) problem that I always get arrays instead
of ResultSet objects when exploring DBIx::Class related tables in TT2, I
came across the Template::Stash::Context module, which is bundled in TT.
By using a view defined this way:
-----
package San::View::TT;
use strict;
use base 'Catalyst::View::TT';
use Template::Stash::Context;
my $stash = Template::Stash::Context->new();
__PACKAGE__->config->{STASH} = $stash;
-----
I'm now able to do things such as this (where songs is a has_many
relation):
[% my_rs = album.songs.scalar %]
and get a ResultSet instead of an array. The downside is that I have to
write ".scalar" everytime I want scalar context, but this seems not too
bad.
Is this a good way to achieve what I'm trying to? Anybody else tried
this? Caveats? ...?
Thanks,
Michele.
--
Michele Beltrame
http://www.varlogarthas.net/
ICQ# 76660101
More information about the Catalyst
mailing list