On Wed, Sep 30, 2009 at 3:00 PM, Wallace Reis <[email protected]>wrote:
>
> > Unable to restore schema at ../../lib/Storable.pm (autosplit into
> > ../../lib/auto/Storable/thaw.al) line 415
> > calling ->cds on deserialized object
> > Can't call method "source" on an undefined value at
> > /usr/local/share/perl/5.10.0/DBIx/Class/R
>
> The error message is clever in 0.08112. You need to 'freeze' and
> 'thaw' your dbic row. Look at DBIC::Schema docs about it.
>
Well, I wonder about that message. That would have me think that the
approach would be to do a Storable round trip like:
$schema->thaw( $schema->freeze( $artist ) );
And then a common use case might be to store an object in a session hash, as
with Catalyst. Are you saying that the recommended approach is this?
$c->session->{foo} = $schema->freeze( $object );
And then later
$object = $schema->thaw( $c->session->{foo} );
Which ends up running through Storable twice.
I wonder if that message should not point to the
DBIx::Class::ResultSourceHandle docs (which is where it is generated from).
There it would point out that you can set
$DBIx::Class::ResultSourceHandle::thaw_schema = $schema;
before thawing and then the Storable hooks will work. There it also
recommends using $schema->thaw, but then it's back to pre-serializing,
unless I'm missing the expected use.
Of course, a global $schema is sometimes not desirable. Perhaps allowing
thaw_schema to be a coderef might be useful as then you could inspect the
deserialized object and have a chance at selecting and returning the correct
schema.
Then, there's DBIx::Class::Serialize::Storable with the synopsis:
my $cd = $schema->resultset('CD')->find(12);
# if the cache uses Storable, this will work automatically
$cache->set($cd->ID, $cd);
What does that do? Freezing isn't the issue. Plus, seems that $cd freezes
and thaws fine without it. And that synopsis isn't showing the
$cache->get. I guess I'm missing the point of that component.
--
Bill Moseley
[email protected]
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]