[CDBI] has_many and Class::DBI::Template

Nigel Drego ndrego at mtl.mit.edu
Sun May 14 04:04:19 BST 2006


I'm trying to use Class::DBI::Template but when I try to do a template
of this form:

MusicDB::Album->has_many(tracks => 'MusicDB::Track');

...

[% FOREACH track IN tracks %]
   [% track.tracknum %] - [% track.title %]
[% END %]

I don't get anything. If I do [% track %] what I end up getting is a
number - in fact the number of tracks. What it looks like is happening
is that between Class::DBI and Template::Toolkit, it's interpreting that
assignment to track as a scalar assignment rather than list-based and as
such Class::DBI->search (which is called deep within
Class::DBI::Relationship::HasMany) is returning a scalar, not a list.
Has anyone else seen this behavior? Is there a work-around? Am I doing
something wrong?

Thanks for any help!
Nigel.



More information about the ClassDBI mailing list