[Dbix-class] Re: Using Storable with DBIx::Class - Can't locate object method "result_source_instance"

Alexander Hartmaier alexander.hartmaier at t-systems.at
Thu Oct 1 07:33:05 GMT 2009


Am Donnerstag, den 01.10.2009, 03:41 +0200 schrieb Bill Moseley:
>
>
> On Wed, Sep 30, 2009 at 3:00 PM, Wallace Reis <reis.wallace at gmail.com>
> 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 ) );

I'd like this more because the $artist knows about his schema, using a
different one might end up in unexpected results:

$schema->thaw( $artist->freeze );

>
>
> 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
> moseley at hank.org
--
best regards, Alex


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*



More information about the DBIx-Class mailing list