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

[prev] [thread] [next] [Date index for 2005/10/13]

From: Will Hawes
Subject: RE: [Templates] Re: [CDBI] Weirdness trying to limit Class::DBI has_many relationship from TT template
Date: 11:58 on 13 Oct 2005
----- Original Message -----
From: Sergey Martynoff <sergey@xxxxxxxxx.xxxx>
To: 'Will Hawes' <info@xxxxxx.xx.xx>
Cc: templates@xxxxxxxxxxxxxxxx.xxx
Sent: Thu, 13 Oct 2005 12:25:07 +0100
Subject: RE: [Templates] Re: [CDBI] Weirdness trying to limit Class::DBI=
 has=5Fmany relationship from TT template


>=20
> > Thanks, that works, but I'm still a bit confused about the=20
> > passing of hashrefs to object methods from within TT. This=20
> > does not work:
>=20
>=20
> > [%
> > criteria =3D {
> >   'image=5Ftype' =3D> 1
> > };
> > images =3D product.images( criteria );
> > %]
>=20
> If 'images' method really expects hashref - this should work ok.
> Try to insert parameters dumping into this method.
>=20
>=20
> > Is the problem here simply that TT doesn't allow you to pass=20
> > a hashref to an object method=3F
>=20
> TT =5Fdoes=5F allow to pass hashref, and even more - it =5Fwill=5F pas=
s a
> hashref when you write code like this (note, that there is no
> curly brackets!):
>=20
> [% images =3D product.images( 'image=5Ftype' =3D> 1 ); %]
>=20
> This is a bit confusing, because there is still modules, which
> accept parameters as hash, not hasref. Example:
>=20
> sub method {
> =09my %params =3D @=5F;
> =09# do something with $params{param=5Fkey}
> }
>=20
> In this case you have to write:
>=20
> [% some.method( 'param=5Fkey', 'param=5Fvalue' ); # passes an array of
> params %]
>=20
> Instead of convenient:
>=20
> [% some.method( param=5Fkey =3D> 'param=5Fvalue' ); # this passes a
> hasref and thus DOES NOT WORK %]
>=20
>=20
> --=20
> Sergey Martynoff

I think that's hit the nail on the head. In Class::DBI::Relationship::Ha=
sMany::=5Fhm=5Frun=5Fsearch(), which does the search for the related cla=
ss, assumes that the search arguments are passed as a list. Unlike the m=
ain search() method for a CDBI class, it doesn't allow a hashref instead=
.


_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

RE: [Templates] Re: [CDBI] Weirdness trying to limit Class::DBI has_many relationship from TT template
Will Hawes 11:58 on 13 Oct 2005

Generated at 15:35 on 18 Oct 2005 by mariachi v0.52