Re: [CDBI] How do I add a method to a loaded class?

[prev] [thread] [next] [Date index for 2005/08/07]

From: Alex Aminoff
Subject: Re: [CDBI] How do I add a method to a loaded class?
Date: 14:41 on 07 Aug 2005
This is a multi-part message in MIME format.

--===============0161671371==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_002D_01C59B3C.91B5C900"

This is a multi-part message in MIME format.

------=_NextPart_000_002D_01C59B3C.91B5C900
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


  ----- Original Message -----=20
  From: John Beppu=20
  To: Alex Aminoff=20
  Cc: classdbi@xxxxx.xxxxxxxxxxxxxxxx.xxx=20
  Sent: Sunday, August 07, 2005 12:13 AM
  Subject: Re: [CDBI] How do I add a method to a loaded class?


  On 8/6/05, Alex Aminoff <alex@xxxxxxxxx.xxx> wrote:

    Very basic newbie question...

    I have loaded up my database into a Class::DBI structure using =
Class::DBI::Loader. Now I would like to add a method to one of the =
autogenerated classes that will calculate some stuff based on various =
data, but otherwise appear in most respects like any other column from =
the DB. I'm pretty sure I want something using MyTable->columns( TEMP =
=3D> calcfield ).


  Let's step back a bit.  Why do you need to have the calcfield() method =
appear as a column?  Isn't it enough that you managed to put the method =
into the MyTable namespace and are able to call it? =20



I want to generate an html table screen of the data, using =
Class::DBI::Plugin::HTML, which appears to rely on ->columns() to find =
out what columns should be displayed. Yes, one could just list the =
columns explicitly, but that defeats the elegance of not having to do =
so; plus, if I change my database schema in mysql, I dont want to have =
to sync up changes in my perl code.

I'm not actually using Class:DBI::Plugin::HTML, but rather my own module =
which will work with HTML::Template, just because that is what I'm =
familiar with already, but the principle is the same.

 - Alex

------=_NextPart_000_002D_01C59B3C.91B5C900
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1491" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Djohn.beppu@xxxxx.xxx =
href=3D"mailto:john.beppu@xxxxx.xxx">John=20
  Beppu</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
title=3Dalex@xxxxxxxxx.xxx=20
  href=3D"mailto:alex@xxxxxxxxx.xxx">Alex Aminoff</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Cc:</B> <A=20
  title=3Dclassdbi@xxxxx.xxxxxxxxxxxxxxxx.xxx=20
  =
href=3D"mailto:classdbi@xxxxx.xxxxxxxxxxxxxxxx.xxx">classdbi@xxxxx.xxxxxx=
lcraftsmen.net</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Sunday, August 07, 2005 =
12:13=20
  AM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Re: [CDBI] How do I =
add a method=20
  to a loaded class?</DIV>
  <DIV><BR></DIV>On 8/6/05, <B class=3Dgmail_sendername>Alex Aminoff</B> =
&lt;<A=20
  href=3D"mailto:alex@xxxxxxxxx.xxx">alex@xxxxxxxxx.xxx</A>&gt; wrote:
  <DIV><SPAN class=3Dgmail_quote></SPAN>
  <BLOCKQUOTE class=3Dgmail_quote=20
  style=3D"PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: =
rgb(204,204,204) 1px solid">
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>Very basic newbie =
question...</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>I have loaded up my database into a =
Class::DBI=20
    structure using Class::DBI::Loader. Now I would like to add a method =
to one=20
    of the autogenerated classes that will calculate some stuff based on =
various=20
    data, but otherwise appear in most respects like any other column =
from the=20
    DB. I'm pretty sure I want something using MyTable-&gt;columns( TEMP =
=3D&gt;=20
    calcfield ).</FONT></DIV></BLOCKQUOTE></DIV>
  <DIV><BR><BR>Let's step back a bit.&nbsp; Why do you need to have the=20
  calcfield() method appear as a column?&nbsp; Isn't it enough that you =
managed=20
  to put the method into the MyTable namespace and are able to call =
it?&nbsp;=20
  <BR></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BLOCKQUOTE>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I want to generate an html table screen =
of the=20
data, using Class::DBI::Plugin::HTML, which&nbsp;appears to rely&nbsp;on =

-&gt;columns() to find out what columns should be displayed. Yes, one =
could just=20
list the columns explicitly, but that defeats the elegance of not having =
to do=20
so; plus, if I change my database schema in mysql, I dont want to have =
to sync=20
up changes in my perl code.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'm not actually using =
Class:DBI::Plugin::HTML, but=20
rather my own module which will work with HTML::Template, just because =
that is=20
what I'm familiar with already, but the principle is the =
same.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;- Alex</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_002D_01C59B3C.91B5C900--



--===============0161671371==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

--===============0161671371==--


(message missing)

[CDBI] How do I add a method to a loaded class?
Alex Aminoff 00:22 on 07 Aug 2005

Re: [CDBI] How do I add a method to a loaded class?
Alex Aminoff 14:41 on 07 Aug 2005

Generated at 09:40 on 09 Aug 2005 by mariachi v0.52