From: Matt G. <ma...@po...> - 2003-07-10 14:56:51
|
Is the transaction support working in 0.4 and CVS? I just tried the following: conn = PostgresConnection(...) trans = conn.transaction() print Person(1, trans) and got "AttributeError: 'Transaction' object has no attribute 'cache'" A quick look at the code implies that the Person ctor was expecting a connection, not a transaction. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: ma...@po... |
From: alejo a. <a_l...@ya...> - 2005-08-29 22:11:22
|
Hi, I have a problem with transaction, when i put commit it's ok but when i put rollback i have some problems like: 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 I don't why. thanks for your advice. from sqlobject import * __connection__ = connectionForURI("sqlite:///home/alejo/base1.db") __connection__.autoCommit=False trans = __connection__.transaction() class PruebaT(SQLObject): _cacheValue = False _connection = trans a = IntCol() class PruebaT1(SQLObject): _cacheValue = False _connection = trans a = IntCol() PruebaT.dropTable(ifExists=True) PruebaT.createTable() trans.commit() #trans.begin() #trans.commit() #trans.rollback() a1 = PruebaT(a=1) a2 = PruebaT(a=2) a1.set(a=3) a3 = list(PruebaT.select(PruebaT.q.id == 2))[0] a3.set(a=7) print "a2 --> ",a2 print "a3 --> ",a3 print a1 #trans.rollback() #trans.commit() #trans.rollback() a2.set(a=5) print "A2: ",a2 #trans.commit() ## __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Kevin D. <da...@gm...> - 2005-08-30 10:57:38
|
I believe that the general philosophy is that when a transaction is rolled back, it is dead. You should get a new transaction from the connection. Kevin On 8/29/05, alejo alejo <a_l...@ya...> wrote: > I have a problem with transaction, when i put commit > it's ok but when i put rollback i have some problems > like: > 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 |
From: Oleg B. <ph...@ma...> - 2005-08-30 11:05:08
|
On Tue, Aug 30, 2005 at 06:57:31AM -0400, Kevin Dangoor wrote: > I believe that the general philosophy is that when a transaction is > rolled back, it is dead. Yes. > You should get a new transaction from the > connection. Just call trans.begin(). Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2005-08-30 13:49:53
|
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. |
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 |
From: Oleg B. <ph...@ph...> - 2005-08-31 17:30:49
|
On Tue, Aug 30, 2005 at 08:52:02AM -0700, alejo alejo wrote: > 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 > > #trans.rollback() trans.rollback() trans.begin() Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Ian B. <ia...@co...> - 2003-07-10 19:28:07
|
On Thu, 2003-07-10 at 10:06, Matt Goodall wrote: > Is the transaction support working in 0.4 and CVS? I just tried the > following: > > conn = PostgresConnection(...) > trans = conn.transaction() > print Person(1, trans) > > and got "AttributeError: 'Transaction' object has no attribute 'cache'" > > A quick look at the code implies that the Person ctor was expecting a > connection, not a transaction. No, I just extended the DBConnection interface to include a cache, and forgot to extend Transaction too. I added this fix to CVS, but my transaction test I added isn't working like I would think it should. Could you look at it? (Maybe I have to turn off autocommit or something...) Ian |
From: Matt G. <ma...@po...> - 2003-07-10 22:32:03
|
On Thu, 2003-07-10 at 20:28, Ian Bicking wrote: > On Thu, 2003-07-10 at 10:06, Matt Goodall wrote: > > Is the transaction support working in 0.4 and CVS? I just tried the > > following: > > > > conn = PostgresConnection(...) > > trans = conn.transaction() > > print Person(1, trans) > > > > and got "AttributeError: 'Transaction' object has no attribute 'cache'" > > > > A quick look at the code implies that the Person ctor was expecting a > > connection, not a transaction. > > No, I just extended the DBConnection interface to include a cache, and > forgot to extend Transaction too. Ah, that would explain it ;-). > I added this fix to CVS, but my transaction test I added isn't working > like I would think it should. Could you look at it? I just updated from CVS and the problem is still occurring. I also can't find the transaction test you mention. > (Maybe I have to turn off autocommit or something...) Almost certainly, PostgreSQL and SQLite both have autocommit on by default. - Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: ma...@po... |
From: Ian B. <ia...@co...> - 2003-07-10 22:34:03
|
On Thu, 2003-07-10 at 17:32, Matt Goodall wrote: > > I added this fix to CVS, but my transaction test I added isn't working > > like I would think it should. Could you look at it? > > I just updated from CVS and the problem is still occurring. I also can't > find the transaction test you mention. I think SF CVS is slow today. Look for this line in Transaction.__init__(DBConnection.py:333): self.cache = CacheSet(cache=dbConnection.doCache) Once you get it you'll know you have a more current CVS. Ian |