[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] Re: OT: Class::DBI passing data to templates


Thanks all for the feedback. I ended up just fixing my param method like so:

sub param{
 my $class = shift;
 my $name=shift;
 my $val=shift;
 return $class->columns() unless $name;
 return $class->set($name=>$val) if $val;
 return $class->get($name);
}

and passing the object in via associate.  Works for my simple purposes. ;)

Mike
----- Original Message ----- From: "Lance A. Brown" <suppressed>
To: "Rhesa Rozendaal" <suppressed>
Cc: "Michael Cameron" <suppressed>; <suppressed>
Sent: Saturday, November 06, 2004 7:28 AM
Subject: Re: OT: Class::DBI passing data to templates


Rhesa Rozendaal wrote:
What I generally do is this:
(1)    $tmpl->param( map { $_->name => $obj->$_() } $obj->columns );

A quick and dirty way is using the private _data_hash method:
(2)    $tmpl->param( $obj->_data_hash );

Beware, _data_hash does *not* populate the field(s) making up the
primary key of the object.  I learned that the hard way.

--[Lance]

--
Carolina Spirit Quest  http://www.carolinaspiritquest.org/
Celebrate The Circle   http://www.celebratethecircle.org/
My LiveJournal  http://www.livejournal.com/users/labrown/
GPG Fingerprint: 409B A409 A38D 92BF 15D9 6EEE 9A82 F2AC 69AC 07B9




---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.