On Feb 11, 2011, at 7:43 AM, Joril wrote:

> Hi everyone!
> I have a client-server application that communicates like this: the
> client asks for something, the server fetches the data using
> SQLAlchemy, serializes it and sends it back to the client. Now the
> client can modify the data and send it back to the server for
> persistence. It works nicely, but I'm having a little problem..
> I'm on the client, with a detached lazy-loaded object having a
> cascaded one-to-many relation, and I just want to clear this relation,
> such as:
> 
> obj.children = []
> 
> but it complains that "obj is not bound to a Session" and that "the
> lazy load operation of attribute 'children' cannot proceed". This used
> to work with SA 0.5.8, but now we're using 0.6.5... What am I missing?

The general idea of collection management hasn't changed since 0.5 so there's 
likely some artifact of your approach that causes different behavior, I would 
guess that the obj.children collection is already present before the object 
moves to the detached state in your 0.5 version.   If you have an object where 
you've emptied all contents of a collection, you then attach to a session and 
flush, we have to identify all those objects which have been removed in order 
to do so.    Since we don't differentiate the case of "collection = []" from a 
piecemeal removal of individual objects, we store each object that's removed in 
a private collection so that an UPDATE or DELETE can be emitted for them at 
flush time, as well as so that the collection itself and the removed members 
can be managed appropriately, such as, if its a dict, we have to replace the 
previous member, if a remove, we may need to update the backref on the target.  
Hence mutations of a collection require that the collection be loaded.


> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to