quick question on the definitive behavior for the orm
I'm have some code that reassigns objects from one owner to another.
instead of objects being assigned directly to an owner, they're assigned
into an intermediary Library, which is then assigned to an Owner
i also keep the owner_Id on the library object as a shorcut/note.
this is a simple example
class Owner :
id
libraries = relationship(Library,uselist=True) creates backref
class Library(object):
id
id_owner - fkey Owner
class Object :
id
library_id - fkey Library
owner_id - fkey Library
library = relationship(Library,uselist=False) creates backref
in my logic I have:
old_owner = Owner.get('Jack')
new_owner = Owner.get('Jill')
object = Object.get('Pail of water')
this is super simple and straigtforward for re-assining an objects from one
library/owner to another
object.library_id = new_owner.library.id
object.owner_id = new_owner.id
i'm working on re-assigning libraries (which also has some internal
bookkeeping), and that's the tricky part for me...
in order to do this properly, i need to load a library , and set the new
owner...
a_library = Library.get(1)
a_library.id_owner = new_owner.library.id
but also loop through the collections
and this becomes my question / worry - I haven't flushed anything to the
database nor have i pre-loaded anything
a) will I be looping based on the 'clean' or 'dirty' values if i change an
FKEY.
b) if it's the 'dirty' value, can I loop based on the clean somehow ?
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.