[CDBI] Re: uniqueness of objects in memory??

Phil Mitchell phil at 2people.org
Tue Oct 25 00:34:33 BST 2005

On 10/24/05, Perrin Harkins <perrin at elem.com> wrote:
> On Mon, 2005-10-24 at 15:07 -0700, Phil Mitchell wrote:
> > OTOH, I can run essentially the same code inside a single template
> > inside my app:
> >
> > [% prefs.home_page %]<br>  => X
> > [% user.prefs.home_page %]<br>  => X
> >
> > [% prefs.home_page('Y') %]<br>
> > [% prefs.update() %]<br>
> >
> > [% prefs.home_page %]<br>  => Y
> > [% user.prefs.home_page %]<br> => X
> >
> > ...and see the weird behavior.
> Possible cloning side effects from the TT stash?
> You can identify if the two refs are pointing to the same object by
> printing their refaddr() values with Scalar::Util.

Yes, they are indeed different! However, my tests suggest it's not an
issue with TT stash cloning. Using refaddr, I can watch what happens
in my controller, and they're distinct before they ever get to the
stash. Apparently CDBI can't see the Prefs object that's referenced by
the User object that's stored in the catalyst session object. I'm
suspicious of the session object, bc I've been able to replicate this
behavior with another class, just by sticking it into the session

For sanity's sake, here's the sequence:

User logs in and User object is saved to session
User has a prefs object
User wants to edit prefs
Prefs object is retrieved from db
Prefs object is updated
User->prefs is not refreshed

> - Perrin

2People Blog: http://2-people.blogspot.com/
2People site: http://www.2people.org

More information about the ClassDBI mailing list