[Templates] DBI attribute problem
[prev]
[thread]
[next]
[Date index for 2004/06/14]
In my perl code I use DBI to create a database connection which is then
passed as a parameter to my templates. In a given template, I want to
alter the "LongReadLen" attribute of the dbh (or any other attr, for
that matter), but it doesn't work. The perl syntax is:
$dbh->{LongReadLen} =3D 10000;
which I write in TT as:
[% dbh.LongReadLen =3D 10000 %]
which doesn't work. The problem seems to be that dbh isn't really a
hashref, it's some kind of kooky magical blessed coderef. So the set()
method of the stash looks at it and says, "It's an object, not a hash,
so I'll try this as a method call rather than a hashkey assigment."
Which doesn't work.=20
I've looked at Template::Plugin::DBI, but I don't see handle attributes
accounted for anywhere in there. Checking the TT list archive, the only
suggestions were: a) set the attr when the dbh is created (in the perl
code, before TT processing), or b) hack/subclass Template::Plugin::DBI.
Option (a) isn't useful because I may want different values in different
templates, and I'd certainly like to avoid the effort of option (b) if I
can. Has anybody out there come up with a better solution?
Jason
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
[Templates] DBI attribute problem
Jason Gottshall 20:01 on 14 Jun 2004
|