Re: [Dbix-class] Re: Using Storable with DBIx::Class - Can't locate object method result_source_instance
Am Donnerstag, den 01.10.2009, 03:41 +0200 schrieb Bill Moseley: On Wed, Sep 30, 2009 at 3:00 PM, Wallace Reis reis.wall...@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 mose...@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. *** ___ 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/dbix-class@lists.scsys.co.uk
Re: [Dbix-class] Re: Using Storable with DBIx::Class - Can't locate object method result_source_instance
On Thu, Oct 1, 2009 at 12:33 AM, Alexander Hartmaier alexander.hartma...@t-systems.at wrote: 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 ); True. Well at for the freeze step anyway. Have to supply a $schema on thaw. (Plus, freeze is not a method on $artist). Back to my original question. Which turned out to be two questions. First, I never got anyone to comment (commit) on how to save dbic objects in a session hash. Is that not done by anyone? Or is it: $c-session-{foo} = $schema-freeze( $foo ); Then later: $foo = $c-$schema-thaw( $c-session-{foo} ) if exists $c-session-{foo}; I assume running the serialized $foo though Storable again is not a significant performance issue. And my original question: Legacy application has session data in Memcached. Runs on separate machines. No DBIx::Class installed (and not sure could install if dependencies cause breakage). New Catalyst application should transparently handle some new pages on application. Users should be able to move seemlessly (and transparently) between two applications. Two applications need to share state information in session back-and-forth. If dbic is not on legacy machines then can't have dbic objects in any data thawed by Storable. Suggestions? Use two different sessions on the new (dbic) application? Do ugly hack on legacy app so that Storeable won't try and load dbic? { no warnings 'redefine'; sub DBIx::Class::ResultSet::STORABLE_thaw {} sub DBIx::Class::ResultSourceHandle::STORABLE_thaw {} $INC{'DBIx/Class/ResultSet.pm'} = 1; $INC{'DBIx/Class/ResultSourceHandle.pm'} = 1; DBIx::Class::ResultSourceHandle-overload::OVERLOAD(q// = sub {}); DBIx::Class::ResultSet-overload::OVERLOAD(q// = sub {}); } -- Bill Moseley mose...@hank.org ___ 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/dbix-class@lists.scsys.co.uk
Re: [Dbix-class] Re: Using Storable with DBIx::Class - Can't locate object method result_source_instance
On Wed, Sep 30, 2009 at 1:10 PM, Bill Moseley mose...@hank.org wrote: $VERSION = '0.08111'; Ok, starting simple, what's the correct way to store and retrieve dbic row objects from Storable? 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. -- wallace reis/wreis Catalyst and DBIx::Class consultancy with a clue Software Engineer and a commit bit: http://shadowcat.co.uk/catalyst/ Shadowcat Systems Limited http://www.shadowcat.co.uk http://www.linkedin.com/in/wallacereis ___ 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/dbix-class@lists.scsys.co.uk
Re: [Dbix-class] Re: Using Storable with DBIx::Class - Can't locate object method result_source_instance
On Wed, Sep 30, 2009 at 3:00 PM, Wallace Reis reis.wall...@gmail.comwrote: 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 mose...@hank.org ___ 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/dbix-class@lists.scsys.co.uk