[Dbix-class] serializing DBIx::Class::ResultSourceHandle
(Followup)
Jose Fonseca
zefonseca at gmail.com
Thu Feb 21 05:37:07 GMT 2008
Hi, sorry for the late reply, been out of the office.
>> DBIx::Class works around Apache::DBI being stupid and does a better job
of it.
We're using Apache::DBI extensively in production with DBIx::Class so to us
it's a real danger if it breaks down. Where, in your experience, was
Apache::DBI causing trouble?
>> Why might I ask? Not doubting you - it just helps to have someone else
check your logic.
"Why" which part ;) ?!
If why... "I really need that object in Apache's session memory"
For speed only and lifting some weight off of the database backend. After I
sent that email I rethought about it and gave up speed for reliability...it
reloads the user object with each request..... I couldn't find the time to
hack the session/freeze/thaw issue until it worked....
Or if why "I am having this problem to start with": here's how I built it,
nothing exceptional : When the user logs in, the app used to store him into
$udat{customer} under Embperl. As you know $udat is the Embperl session hash
and is normally tie'd to a session handling module(Apache::SessionX here).
And the rest is known here from my previous posts,
$udat{customer}->{_source_handle}->{schema} is undef when thaw'ed(more
precisely when freeze'd)....
Temporary Solution (Because I frustrated that I could not find the time
right now to hack further) : to reload the $udat{customer} object on top of
each page and let dbix::class and the database handle the bang. It could be
stored into any variable really since I'm not using the session now....but I
did this on purpose just in case the session method worked in the near
future, I could just remove the hack and let the session work again via
%udat without reloading each page.
Thanks again for your time and best regards.
Ze
On Sat, Feb 16, 2008 at 8:18 AM, Ash Berlin <ash_cpan at firemirror.com> wrote:
>
> On 16 Feb 2008, at 02:37, Jose Fonseca wrote:
>
> Sure. I asked because I'm working under Apache so freezing that DBH works
> just fine. Apache::DBI will give you a brand new DBH everytime your DBH is
> obsolete.
>
>
> No it wont. It will try to and will get it wrong. DBIx::Class works around
> Apache::DBI being stupid and does a better job of it.
>
>
>
> Thanks for the pointer, I had not seen your solution in Schema.pm,
> appreciate that. I either have to plug that into Apache::SessionX instead=
of
> Storable or continue to $data->result_source($schema->source('User')); li=
ke
> Matt Trout suggested.
>
> What I know is that I really need that object in Apache's session memory
> and not let it be recreated each time from disk(or dbh).
>
>
> Why might I ask? Not doubting you - it just helps to have someone else
> check your logic.
>
>
>
> Regards,
> Ze
>
>
> On Feb 15, 2008 6:20 PM, Ash Berlin <ash_cpan at firemirror.com> wrote:
>
> > Cos it contains a code-ref (the DBH) which can't be freezed.
> > But since then I did come up with *a* way of doing it:
> >
> >
> > http://search.cpan.org/~jrobinson/DBIx-Class-0.08009/lib/DBIx/Class/Sch=
ema.pm#thaw<http://search.cpan.org/%7Ejrobinson/DBIx-Class-0.08009/lib/DBIx=
/Class/Schema.pm#thaw>says
> >
> > Provided as the recommened way of thawing schema objects. You can call
> > Storable::thaw directly if you wish, but the thawed objects will not
> > have a reference to any schema, so are rather useless
> >
> >
> >
> > There are also freeze and dclone methods for symmetry. This was a new
> > addition since 0.08009 2008-01-20 13:30
> >
> > -ash
> >
> >
> > On 15 Feb 2008, at 19:57, Jose Fonseca wrote:
> >
> > Hi, I just had the same problem that Bernhard Graf had in Sept. 2007 and
> > caught up with this discussion:
> >
> > Ash Berlin Wrote:
> > "I wrote the ResultSourceHandle stuff, and I never could come up with a
> > good way of specifying what schema to use in thawing the data."
> >
> > Quick question: why is the "schema" column of _source_handle undef'd
> > when freeze()ing?
> >
> >
> > On Thu, Sep 20, 2007 at 10:18:10AM +0200, Bernhard Graf wrote:
> > >* On Thursday 20 September 2007 09:42, Ash Berlin wrote:
> > *>*
> > *>* > I wrote the ResultSourceHandle stuff, and I never could come up w=
ith
> > *>* > a good way of specifying what schema to use in thawing the data. =
So
> > *>* > currently you'd have to do
> > *>* >
> > *>* > $data->_source_handle->schema($schema);
> >
> > *>*
> > *>* Not pretty, but this works at least.
> > *
> > $data->result_source($schema->source('User'));
> >
> > just like it's always been since before ResultSourceHandle existed.
> >
> >
> >
> > Never call an _ prefix method from outside the object or a subclass the=
reof.
> >
> > --
> > Matt S Trout Need help with your Catalyst or DBIx::Class pr=
oject?
> > Technical Director http://www.shadowcat.co.uk/cat=
alyst/
> >
> >
> > Shadowcat Systems Ltd. Want a managed development or deployment platf=
orm?
> > http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/ser=
vers/
> >
> >
> _______________________________________________
> 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.rawmode.org
>
-- =
http://zefonseca.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20080221/f62=
359ae/attachment.htm
More information about the DBIx-Class
mailing list