Hi Michael,

Nope! Nothing of that sort. I couldn't care less about transaction at this 
point.

All I do is 

        
        self.dbEng=sqlalchemy.create_engine(myurl,strategy='threadlocal')
        #debug
        self.dbEng.echo=True
        try:
            self.dbConn=self.dbEng.connect()
            self.dbSession=sqlalchemy.create_session(bind_to= self.dbConn)
        except sqlalchemy.exceptions.DBAPIError,msg:
            QMessageBox.critical(None,"Race Management","Problem with the 
                              database: "+str(msg))
            sys.exit(-1)

After that all I do is create "dbPeople", set the needed properties and issue 
a "flush" on the one session I have.  

I did trigger the problem I described at least twice And once more just now). 
The behaviour was exactly the same in all cases. 

I installed SQLAlchemy using the standard Gentoo command (emerge), a md5sum on 
the file used in the install gives
        
fd9898c75d2773d075db89c6a99d31d6  /usr/portage/distfiles/SQLAlchemy-0.2.8.tar.gz

Regards,
        François




> hey François -
>
> are you using the SessionTransaction explicitly ?  or connection.begin
> () ?   Ive tried many combinations, and the only way I can reproduce
> the problem is by doing something incorrect:
>
>          c = engine.connect()
>          s = create_session(bind_to=c)
>
>          tran = c.begin()
>          session_tran = s.create_transaction()
>
>          s.save(User())
>          s.flush()
>          u = User()
>          s.save(u)
>          s.user_name = 'some user'
>
>          tran.commit()
>          session_tran.commit()
>
> the reason the above is incorrect is because the "Transaction" and
> "SessionTransaction" are not nested properly.
>
> The fix you have wouldnt be correct since the SessionTransaction is
> being closed (if not the underlying connection, which was the
> original bug), so it should remove its association from its host
> Session.
>
> On Oct 20, 2006, at 6:59 AM, François Wautier wrote:
> > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to