On Tue, Nov 04, 2003 at 04:59:46PM -0500, Perrin Harkins wrote:
> On Tue, 2003-11-04 at 15:54, Jesse Sheidlower wrote:
> > In my calling program, I retrieve values from a database into
> > a $data_ref hash, and insert them into the parameter space with:
> >
> > foreach my $key (keys(%$data_ref)) {
> > CGI::param(-name => $key, -value => $data_ref->{$key});
> > }
>
> You're using CGI.pm as a way to pass parameters around? I wouldn't do
> that. Better to pass them directly to TT.
Well, I'm refactoring an earlier program that used this
process as an easy way of moving data back and forth; the
point there was to be able to use it for stickiness when
necessary.
> > Later I call $tt->process..., and my page, including forms,
> > appear, but empty aside from the defaults, with no sticky
> > values held therein.
>
> If you call CGI.pm before you call TT and read some POST data, that data
> won't be available to read again later when TT tries to create a new
> instance of CGI. I'm not sure what will happen, but I think the basic
> deal is that you shouldn't use from your calling program and as a TT
> plugin at the same time. One alternative is to simply pass the CGI
> object in to TT along with the rest of your data. I don't think there's
> any special reason to use the plugin if you already have a CGI object
> handy.
The original program was using the functional, not the OO, interface
to CGI.pm, thus I don't have a CGI object handy. So I suppose in this
case it would make more sense to use a data structure right from the
database; optimally I shouldn't be using CGI from this program anyway,
as it would defeat whatever slight MVC setup I now have going.
Thanks. I'll try this. Will probably be a pain to figure out the
necessary overrides and so forth for those times when I'm not
using the database values, but I'll try.
Best,
Jesse
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates