Hi Michael,
It seems I spoke too quickly.
The problem is now when I try to flush a second time with a new object.
Something like this
newguy=dbPeople()
session.save(newguy)
newguy.Lastname="Doe"
newguy.Firstname="John"
newguy.gender="Ambiguous"
session.flush()
newguy=dbPeople()
session.save(newguy)
newguy.Lastname="Doe"
newguy.Firstname="Jane"
newguy.gender="Sheila"
session.flush()
The last session flush results in a new record being written to the database,
but an exception is raised, with the error message
This transaction is inactive
If one were to try to add more dbPeople, the records won't be saved into the
database for the session keeps on using the same key value (the table uses
an "auto_increment")
I hacked the code a bit and I solved the problem.... but I am far from sure
that I did the right thing for all cases
In lib/sqlalchemy/orm/session.py around line 67 I changed
for t in self.connections.values():
if (t[2]):
t[0].close()
self.session.transaction = None
into
keeptransaction=False
for t in self.connections.values():
if (t[2]):
t[0].close()
else:
keeptransaction=True
if not keeptransaction=False:
self.session.transaction = None
I wonder if something like this would not be preferable (but I again, I have
no clue as to what the consequences of my code is)
closeall=False
for t in self.connections.values():
if (t[2]):
closeall=True
if closeall:
for t in self.connections.values():
t[0].close()
self.session.transaction = None
Regards,
François
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---