I'm working on developing an API that, among other things, allows for 
partial updates or insertions to a parent's children.  One minor problem 
that I've found is that any access to parent.children loads the entire 
collection -- when in many cases it's not necessary to do so.  

For instance, statements like these -- in a one-to-many relationship (or 
potentially some forms of many-to-many relationships, but that's outside my 
current use-case.)

# Add a new child to parent.children.  All's this really does is set 
child.parent_id, so it doesn't need to know anything about other children
parent.children.append(new_child)  # lists
parent.children.add(new_child)  # sets

# Determine if a particular child belongs to this parent... basically 
returning child.parent is parent or child.parent_id == parent.id
child in parent.children

# Remove a particular child from a parent
parent.children.remove(child)  # Raise keyerror if child not in 
parent.children, 

I'd like to find a way to mimic this in a way that still allows for 
'normal' load strategies -- i.e. still allowing "for child in 
parent.children" to work as normal (triggering the load at that time.) 
 Ideally, there'd be a way to get at just the modifications as well.

Any thoughts on how I might accomplish this?

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to