[CDBI] Multiple inflate CODE references

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

From: Kevin White
Subject: [CDBI] Multiple inflate CODE references
Date: 09:52 on 07 Oct 2005
Hi Folks,

I am new here so forgive me if this has come up before, I couldn't  
find anything in the archives so I thought I would post and get some  
thoughts. I have a table structure with the following has_a  
relationships:

__PACKAGE__->has_a( expire_date => 'Time::Piece',
     inflate => sub { Time::Piece->strptime( shift, "%Y-%m-%d" ) },
     deflate => 'ymd',
);

__PACKAGE__->has_a( start_date => 'Time::Piece',
     inflate => sub { Time::Piece->strptime( shift, "%Y-%m-%d" ) },
     deflate => 'ymd',
);

(Code is unashamedly ripped from the CDBI docs)

Trouble was I kept getting the following:

Can't store CODE items at /Library/Perl/5.8.6/Class/DBI.pm line 1039,  
<IN> line 79.

The line in questions is:

     my %hash = %{ dclone($class->__meta_info || {}) };

So what was happening is the first code reference went in with no  
problem as there was no attempt to serialize the object but the  
second has_a tried to serialize the object and fails cause you can't  
store CODE references with Storable.... unless you add the following:

$Storable::Deparse = 1;
$Storable::Eval = 1;

a la http://search.cpan.org/~ams/Storable-2.15/ 
Storable.pm#CODE_REFERENCES

Which I did and all things seem to work well now.

My question is, is there a reason that doing this is a bad idea?

Thanks for any thoughts.

Kevin



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

[CDBI] Multiple inflate CODE references
Kevin White 09:52 on 07 Oct 2005

Re: [CDBI] Multiple inflate CODE references
William Ross 10:11 on 07 Oct 2005

Generated at 10:29 on 10 Oct 2005 by mariachi v0.52