Hi, Scott,

The last email John sent outlines the key steps for creating and
handling new/custom columns. This is my effort to give you an example
how I dealt with creating custom column.

(attached 3 files)

My goal is to have transparent serialization/de-serialization of perl
structures into blob columns.

First, I defined in my custom Metadata class (Metadata.pm, lines
18-20) that blob types of columns will be handled by my custom column
class -- Metadata::Column::Storable.  I created the column class by
stripping down Metadata::Column::Bitfield (as John suggested) class
from RDBO package. Then I specified which will be the method maker for
this column (Metadata_Column_Storable.pm, line 23) -
MakeMethods::Storable. Again, I took `bitfield' sub from
Rose::DB::Object::MakeMethods::Generic and actually wrote the code for
serializing/de-serializing.

For your case, you should write your time handling functions in the
latter module and just global replace 'storable' with 'mypgtime' in
former 2 modules.

Hope that helps!

On separate subject: John, thank you for bringing the attention to
RDBO::Util's functions is_loading/is_saving -- I used to use
undocumented STATE_LOADING() as seen in bitfield.

Regards,
Svi


2006/1/11, Svilen Ivanov <[EMAIL PROTECTED]>:
> Hi Scott,
>
> I've done something similar you want to. I use blob column to store
> arbitrary perl structure in serialized way (via Storable) and retrieve
> it back and un-serialize it transparently. I'll send you my sample
> code for reference in few hours (when I get home).
>
> Generally, your goal can be achieve by adding load/save triggers on
> standard column types. Check this:
> http://search.cpan.org/~jsiracusa/Rose-DB-Object-0.62/lib/Rose/DB/Object/Metadata/Column.pm#TRIGGERS
>
> Also, you can follow this thread discussing inflating/deflating values
> in DB with triggers:
> http://sourceforge.net/mailarchive/forum.php?thread_id=9267247&forum_id=46239
>
>
> 2006/1/11, Scott Karns <[EMAIL PROTECTED]>:
> > Hello again.
> >
> > I've made significant progress in my understanding of
> > RDBO since I last requested help here, thanks again,
> > John.
> >
> > My current problem is that the database I'm working
> > with contains two column types that are specific to
> > postgres and don't seem to be supported by RDBO. The
> > first I alluded to in an earlier message, the 'OID'
> > column type that I am using to store what amounts to
> > blob data (an image file actually) and the second is a
> > 'time' column type used to store class (as in school)
> > scheduling information. For now, I can make do without
> > the 'OID' column type, but it's critical that I be
> > able to use the 'time' type.
> >
> > After looking through some of the RDBO::Metadata
> > space, I believe my best bet is to create a new scalar
> > column class that will convert the Pg data to an
> > integer upon access and back to the Pg form upon store
> > as well as some ability to play well with timestamp
> > objects.
> >
> > My problem is that I'm struggling a bit with the OO
> > aspect of the code and could use some guidance about
> > how best to approach this. I feel like I'm asking for
> > someone else to write the code, but I'm really only
> > looking for some help getting started.
> >
> > Scott
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> > for problems?  Stop!  Download the new AJAX search engine that makes
> > searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> > http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> > _______________________________________________
> > Rose-db-object mailing list
> > Rose-db-object@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/rose-db-object
> >
>

Attachment: MakeMethods_Storable.pm
Description: Binary data

Attachment: Metadata.pm
Description: Binary data

Attachment: Metadata_Column_Storable.pm
Description: Binary data

Reply via email to