[Dbix-class] Problems with DBIx::Class and Template::Toolkit

Oleg Pronin syber.rus at gmail.com
Tue May 8 09:42:03 GMT 2007


I'm not sure. Possible version of your problem.

TT evaluates your expression in LIST contex (it does internally
$stash->get(...) which works in list context in ::Stash::XS i suppose).

Therefore when you call
rs.search(1).search(2).all,
rs.search is executed in list context and not a resultset returned!

To solve the problem, use subexpressions (between periods (".")) that do not
depend on context.

rs.search_rs(1).search_rs(2).all

In case of relationships:

Instead of

[% list =3D user.categories.search(COND) %]

Use
[% list =3D user.related_resultset('categories').search(COND) %]
or
 [% list =3D user.related_resultset('categories').search_rs(COND).all %]



2007/5/8, Jonas B. Nielsen <jonasbn at gmail.com>:
>
> Hello,
>
> I am experiencing some problems with DBIx::Class and
> Template::Toolkit and my workarounds lead to unnessesary and ugly
> bodies of code.
>
> I am using MIME::Lite::TT::HTML in conjunction with DBIx::Class.
>
> I am parsing an order object to: MIME::Lite::TT::HTML and everything
> works fine for some of the order attributes, but when I have a look
> at the orderlines associated
> with the order, I do not get all the necessary data.
>
>     my %params =3D (
>         customer =3D> $member,
>         order    =3D> $order,
>     );
>
> order.id gets shown and I then do a FOREACH in the template to
> iterate over the orderlines:
>
> [% FOREACH orderline =3D order.orderlines %]
>
> This gives me: orderline.label
>
> But the moment I start digging into the object structure I do not get
> any data:
>
> Examples:
>
> orderline.carticle.carticles2prices.first.price
> orderline.vat.rate
>
> My orderlines.t show perfect data for the same syntax in Perl land,
> but in TT nothing.
>
> I will gladly provide a working demonstration of my problem, but for
> know I just need to hear if any of you have some pointers to
> solutions to this problem, before spending too much time attempting
> to isolate this.
>
> jonasbn
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive:
> http://www.mail-archive.com/dbix-class@lists.rawmode.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070508/8fa=
55e29/attachment.htm


More information about the Dbix-class mailing list