Hello,
This is the situation:
I am using Qt with its tree view to display data coming from sqlalchemy.
Mapped classes are used as nodes for the tree. Relations define the
connections to children and parent. As for the QTreeViews model data
structure a sqlalchemy list returned by a query is used. This works great
for displaying. Appending a new instance to a relation of one of the
objects in the list and committing the changes afterwards, leaves the tree
structure somehow unstable, meaning the internal pointers to the instances
in the list change. The problems seems to be caused by the
session.commit(). If I leave it out all seems to be fine, the tree
displays and populates correctly on adding instances, but of course the
changes are not reflected in the DB.
My first question is: What exactly is the commit doing to the list
returned from the query so that pointers to other objects are "lost"
(python.exe will crash on me then)?
Looking for a solution I came across the sessions weak_identity_map
argument, which I set to False and both committing and populating the tree
seems to work fine (because strong references are kept?). But well, I do
not understand the implications this will have on my application. Will it
be faster/slower, will it need more memory, will I need to handle
instances different....? Or is it just an alternative way of doing things?
Can you please enlighten me on this?!
Or is there another solution? Is the design of my data structure (meaning
having mapped classes simultaneously as tree nodes) crap?
Thank you for helping
Sebastian
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.