Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Implement Object Persistence (II)

by dragonchild (Archbishop)
on Apr 29, 2005 at 11:01 UTC ( [id://452626]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Implement Object Persistence (II)

I've submitted the following to jhuckaby (maintainer of DBM::Deep) as a bug report.
use DBM::Deep; use Data::Dumper; use Test::More no_plan => 1; package Foo; sub new { my $c = shift; bless { @_ }, $c } package Bar; sub new { my $c = shift; bless { @_ }, $c } package main; my $dbh = DBM::Deep->new( 'db.db' ); my $foo = Foo->new( bar => Bar->new( x => 1 ), ); my $expected = Dumper( $foo ); $dbh->import( foo => $foo ); my $foo2 = $dbh->export( 'foo' ); my $actual = Dumper( $foo2 ); is( $actual, $expected );

The Perfect is the Enemy of the Good.

Replies are listed 'Best First'.
Re^2: Implement Object Persistence (II)
by merlyn (Sage) on Apr 29, 2005 at 11:52 UTC
      It's, at the very least a doc bug, in that the POD doesn't have this limitation in the CAVEATS. I originally thought it was an implementation bug, but the author responded and said it wasn't.

      So sorry, but DBM::Deep doesn't handle objects (i.e. blessed hashes). It only supports anonymous hashes and arrays. Anything blessed will not be stored blessed. I considered adding this feature, but many classes don't appreciate having their hashes tied. Its on my to-do list for a future release, however.

      I think it can be done, but that requires maintaining a separate metadata structure which may require a complete redesign of the file layout.


      The Perfect is the Enemy of the Good.

        Well, I read the very same docs you did (I presume), and I never got the impression that it would store objects. Interesting how we saw two entirely different things in the docs.

        And frankly, I wouldn't want it to store objects. The design is clean... adding blessings alongside would clutter up the protocols needed to access the existing metadata. If you send it an "export" call, should it be DBM::Deep's export, or the native object export? That's the kind of confusion you'd get by permitting objects in the mix.

        -- Randal L. Schwartz, Perl hacker
        Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://452626]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.