4 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: association proxy er...| From | Sent On | Attachments |
|---|---|---|
| Paul K | 29 Apr 2008 09:01 | |
| Paul K | 29 Apr 2008 09:08 | |
| jason kirtland | 29 Apr 2008 11:49 | |
| Paul K | 29 Apr 2008 13:43 |
| Subject: | [sqlalchemy] Re: association proxy error: stale association proxy![]() |
|---|---|
| From: | Paul K (paul...@gmail.com) |
| Date: | 04/29/2008 01:43:55 PM |
| List: | com.googlegroups.sqlalchemy |
Thanks. That fixed what I was seeing.
Paul Kippes
On Apr 29, 1:49 pm, jason kirtland <j....@discorporate.us> wrote:
Paul K wrote:
The following code duplicates a situation I'm seeing with the association proxy. There are at least two ways I can avoid having the error happen. But since I wasn't sure if the error is a usage error, I wanted to post here first before implementing my work around. One work around for the test code is to delete/comment out line 77 (commented as such). I understand why I'm seeing the error. But should the user really be required to keep the parent around in a variable? I would have thought that the session would be tracking each successive changes.
This is fixed in the trunk @ r4593. The issue was in association proxy's handling of a stale cache attribute it stashes on instances and was fundamentally:
p_copy = copy.copy(parent) del parent p_copy.kids.append(a_kid) # previously, boom
That's similar to what was going under the orm hood with the modified instances coming in and out of scope in have_a_kid.
The patch in the trunk is pretty small, but if that's not an option you can work around the issue somewhat painfully by removing the cache attribute from instances:
for attr in dir(p_copy): if attr.startswith('_AssociationProxy_kid_associations_'): delattr(p_copy, attr)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqla...@googlegroups.com
To unsubscribe from this group, send email to
sqla...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---




