[CDBI] Weirdness trying to limit Class::DBI has_many relationship from TT template

Will Hawes info at whawes.co.uk
Thu Oct 13 12:28:03 BST 2005


----- Original Message -----
From: Dave Howorth <dhoworth at mrc-lmb.cam.ac.uk>
To: Class DBI <classdbi at lists.digitalcraftsmen.net>
Sent: Thu, 13 Oct 2005 11:49:40 +0100
Subject: Re: [CDBI] Weirdness trying to limit Class::DBI has_many relationship	from TT template

> That's the best way to write the call to that method, but it's not true 
> to say that TT doesn't recognize =>. If you write:
> 
>    [% images = product.images(image_type => 1); %]
> 
> TT converts it into Perl something like this:
> 
>    $images = $product->images({ image_type => 1 })
> 
> Note the extra braces { }. And image_type is quoted automatically. (But 
> it's not really manipulating variables called $images etc  - that's just 
> for explanation :)

If this is the intended behaviour of TT (which I had assumed), it's not what I'm seeing. If I use the above syntax, the limit criteria are ignored.

> 
> Perhaps more interesting:
> 
>    [% obj.meth( a => 1, b, c => 2, d ) %]
> 
> becomes
> 
>    $obj->meth(b, d, { a => 1, c => 2 });
> 
> If you're writing methods to be called from templates, it's best to plan 
> to allow this calling style, otherwise people get frustrated when they 
> write => in the template without thinking! So enhancing the images 
> method might be the best thing to do.

I'm not sure how (if?) it needs to be modified. In this instance my images method has been created automatically by CDBI's has_any mechanism.





More information about the ClassDBI mailing list