From: alejo a. <a_l...@ya...> - 2005-08-30 15:52:10
|
Hi, i don't understand exactly why is the error when i put trans.rollback() in following: below is the code. 1) if i comment the last 2 transactions the database is correct because a1=1 and a2=2 (i didn't finish the transaction) 2) if i only put trans.commit() the database is correct because a1=3 and a2 = 2 3) But if i only put trans.rollback() the answer is error assert not self._obsolete, "This transaction has already gone through COMMIT/ROLLBACK; create another transaction" AssertionError: This transaction has already gone through COMMIT/ROLLBACK; create another transaction is really important to make transaction special in this case trans.rollback() please help me with the code. thanks a lot for your advice ---------------------------- from sqlobject import * __connection__ = connectionForURI("sqlite:///home/alejo/Reforma/agosto/TrabajoCVS/base/base1.db") __connection__.autoCommit=False trans = __connection__.transaction() class PruebaT(SQLObject): _cacheValue = False _connection = trans a = IntCol() PruebaT.dropTable(ifExists=True) PruebaT.createTable() trans.commit() a1 = PruebaT(a=1) a2 = PruebaT(a=2) trans.commit() print "after commit-> ",a1 a1.set(a=3) print "before rollback-> ",a1 trans.commit() #trans.rollback() print "after rollback-> ",a1 --- Oleg Broytmann <ph...@ph...> wrote: > On Tue, Aug 30, 2005 at 05:05:12AM -0700, alejo > alejo wrote: > > trans.begin() > > You've already created the transaction, you don't > need to explicitly > begin it. > > [skip] > > trans.commit() > > trans.begin() > > And you don't need to begin it after a commit - > only after a rollback. > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ > ph...@ph... > Programmers don't die, they just GOSUB > without RETURN. > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software > Conference & EXPO > September 19-22, 2005 * San Francisco, CA * > Development Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects > & Teams * Testing & QA > Security * Process Improvement & Measurement * > http://www.sqe.com/bsce5sf > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs |