Re: [SQLObject] Why Transaction.commit() does not _makeObsolete() like rollback() ?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: gian p. c. <gp....@su...> - 2005-02-12 20:25:21
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Oleg Broytmann wrote: | On Sat, Feb 12, 2005 at 08:21:00PM +0100, gian paolo ciceri wrote: | |>It is difficult for me to understand why, without a specific reason, |>I've to re-create a transaction after a commit | | | I do not understand the question. In my code, at least, I never | recreate the transaction. | | Oleg. Oleg, you're right. I've re-checked the code snippet I sent to the ML this morning when I was not aware of this side effect because of the asymmetric behaviour of commit() and rollback() Please let me re-paste and annotate to explain: - ---- ~ 1 trx =3D conn.transaction() ~ 2 ~ 3 p2 =3D Person.get(39, trx) ~ 4 print p2 ~ 5 p2.middleInitial =3D 'k' ~ 6 trx.commit() ~ 7 ~ 8 ### here I must create a new transaction <--- WRONG ~ 9 trx =3D conn.transaction() 10 11 ### I cannot simply begin another <--- WRONG 12 #trx.begin() 13 p2.middleInitial =3D 'q' 14 trx.rollback() 15 <--- HERE I'VE NOT CALLED trx.begin() 16 print 'rollback:', p2 <--- and I ask for p2, still under trx. - ---- Since commit() does not require a successive begin() while rollback does, I've solved the problem at line 15 (lack of a begin() after a rollback()) using another, different transacion, initiated at line 9, (in fact if you try to debug=3D1 the connection, you'll see two different ones). From this point I *wrongly* inferred you need to re-create the transaction after the commit. At this point a wrapper like yours is needed to be sure to begin() the transaction after the rollback(). I still have to understand the reason for this different behaviour between commit() and rollback() in the library, but almost now all the samples make sense. Many thanks for your patience. Regards /gp - -- s=E8mm t=FCcc padreterni, s=E8mm t=FCcc ciulandari. (De Sfroos). gian paolo ciceri via g.marconi 5 - 22036 erba CO Italy mobile : ++39 340 7218101 eMail : gp....@ac..., gp....@su... webSite: http://www.suddenthinks.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Darwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCDmYE5CXmEF0gaHgRArJYAJ9I7mkrEwf9yS5BRmx6HCu1i/LR5QCeLyaE jjdASgYD+KaD8Z8uIuB3r0M=3D =3DpO+D -----END PGP SIGNATURE----- |