[Catalyst] One result / Multiple results
David Naughton
naughton at umn.edu
Mon May 30 08:15:20 CEST 2005
On Sun, May 29, 2005 at 10:37:19PM -0700, Bill Moseley wrote:
> On Mon, May 30, 2005 at 12:22:34AM -0500, David Naughton wrote:
> > [% FOR a_list = one_result.data.list %]a:[% a_list.name %]#
> > [% END %]
> >
> > Both "one_result" and "multiple" are CDBI Iterators, so why not this
> > instead?
> >
> > [% WHILE (a_list = one_result.next) %] ... [% END %]
>
> It's late and I'm asking without testing or thinking much about this,
> but seems like I'd want to do this:
>
> [% FOR a_list = one_result %]
>
> in other words, have the fact that it's an iterator be transparent
> inside TT -- as if it was a plain array ref.
That's fine, except that it won't work without also changing code in the
controller, e.g.
my @objs = $model_class->search_like( .. );
$c->stash->{one_result} = \@objs;
See the CDBI docs regarding iterators and list vs. scalar context.
If we're addressing Chisel's problem, this is really a CDBI question, in
which case we're getting OT. So I hope this response will close out this
thread.
David Naughton
> --
> Bill Moseley
> moseley at hank.org
More information about the Catalyst
mailing list