SPUG: Re: Storable and DBI

Doug Beaver doug at beaver.net
Sun Oct 27 16:41:51 CST 2002


On Sun, Oct 27, 2002 at 11:44:00AM -0800, Ryan Parr wrote:
> I would assume that because the DBI object needs to be instantiated by
> calling the DBI->connect method, that it would not be properly
> restored. All that serialization can do is print out the object,
> probably a hash reference, and the name of the class it was
> instantiated to. So when you restore you recover the member data
> stored in the object, but no methods that were called on the original
> object can be recalled.

this is because Storable can't properly serialize code refs, globs or XS
code.  it might not work well on tied variables either, that no magic
error leads me to believe it expected that key to be tied.  if you create
simple pure perl classes that hold data, storable works pretty well, but
if your object has state that isn't stored in its keys (say it's an XS
object or has references to an open socket or fd) or it uses globs or
code refs, it won't serialize properly.  sometimes you get helpful
errors like creede mentioned, sometimes you just get a segv or undef is
returned.

doug

> -- Ryan
> 
> ----- Original Message -----
> From: "Creede Lambard" <creede at penguinsinthenight.com>
> To: <spug-list at pm.org>
> Sent: Saturday, October 26, 2002 5:08 AM
> Subject: SPUG: Storable and DBI
> 
> 
> 
>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>      POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
>       Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
>   Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
>  For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
>      Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
> 

-- 
Space Ghost: Moltar, I have a giant brain that is able to reduce any
             complex machine into a simple yes or no answer.
     Moltar: Okay, but that's not the cd burner...
Space Ghost: Moltar! <pause> Yes!

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list